1 # Program to determine -Ttext parameter for ld
2 # $Id: //depot/rel/Cottonwood/Xtensa/OS/xtos/textaddr#2 $
4 # Copyright (c) 2001 Tensilica Inc.
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:
14 # The above copyright notice and this permission notice shall be included
15 # in all copies or substantial portions of the Software.
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.
31 $::myname = 'textaddr';
33 die("Usage is: $::myname objfile label address\n")
35 my($objfile, $label, $address) = @ARGV;
38 my $nm = new FileHandle "xt-nm $objfile|";
39 die("$::myname: $!, opening pipe to xt-nm $objfile.\n")
42 if (/^([0-9a-f]{8}) . (\w+)$/) {
45 if ($olabel eq $label) {
46 printf ("0x%x\n", hex($address) - hex($oaddress));
51 die ("$::myname: $label not found in $objfile.\n");
58 # cperl-indent-level:2