Setting up repository
[linux-libre-firmware.git] / ath9k_htc / sboot / magpie_1_1 / sboot / athos / src / xtos / textaddr
1 # Program to determine -Ttext parameter for ld
2 # $Id: //depot/rel/Cottonwood/Xtensa/OS/xtos/textaddr#2 $
3
4 # Copyright (c) 2001 Tensilica Inc.
5 #
6 # Permission is hereby granted, free of charge, to any person obtaining
7 # a copy of this software and associated documentation files (the
8 # "Software"), to deal in the Software without restriction, including
9 # without limitation the rights to use, copy, modify, merge, publish,
10 # distribute, sublicense, and/or sell copies of the Software, and to
11 # permit persons to whom the Software is furnished to do so, subject to
12 # the following conditions:
13 #
14 # The above copyright notice and this permission notice shall be included
15 # in all copies or substantial portions of the Software.
16 #
17 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
25 package textaddr;
26
27 use strict;
28 use FileHandle;
29
30 {
31   $::myname = 'textaddr';
32
33   die("Usage is: $::myname objfile label address\n")
34       unless @ARGV == 3;
35   my($objfile, $label, $address) = @ARGV;
36   
37
38   my $nm = new FileHandle "xt-nm $objfile|";
39   die("$::myname: $!, opening pipe to xt-nm $objfile.\n")
40       unless $nm;
41   while (<$nm>) {
42     if (/^([0-9a-f]{8}) . (\w+)$/) {
43       my $oaddress = $1;
44       my $olabel = $2;
45       if ($olabel eq $label) {
46         printf ("0x%x\n", hex($address) - hex($oaddress));
47         exit(0);
48       }
49     }
50   }
51   die ("$::myname: $label not found in $objfile.\n");
52 }
53
54\f
55 # Local Variables:
56 # mode:perl
57 # perl-indent-level:2
58 # cperl-indent-level:2
59 # End: