joinSymbols
1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/powderkeg/local/bin/perl5
#
# Copyright (C) 1996-1998 by the Board of Trustees
# of Leland Stanford Junior University.
#
# This file is part of the SimOS distribution.
# See LICENSE file for terms of the license.
#
###
### joinSymbols [unix [ann.simos]]
###
$unix = ($ARGV[0]) ? $ARGV[0] : "$ENV{'ROOT'}/usr/sysgen/SIMMPboot/unix.kdebug";
$deffile = ($ARGV[1]) ? $ARGV[1] : "anngen.ann";
open(NMINFO, "nm -B $unix |");
while(<NMINFO>) {
($addr,$dummy,$symbol) = split();
$hexAddr = hex($addr);
$symbolTable{$symbol} = $hexAddr;
}
open(INPUT, $deffile);
while(<INPUT>) {
if( /^(\w+)\s+(\w+)(\+(\d+))?\s+(\w+)/) {
$op = $1;
$symbol = $2;
$offset = $4 || 0;
$addr = $5;
$remaining = $';
if ($symbolTable{$symbol}) {
$addr = $symbolTable{$symbol} + $offset;
} else {
print STDERR "WARNING: cannot find symbol $symbol. Using old value!\n";
$addr = hex($addr);
}
$symoff = sprintf("$symbol+$offset");
printf("$op %-22s 0x%08x $remaining",
$symoff,$addr);
}
}