joinSymbols 1.12 KB
#!/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);
    }
}