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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
|
#!/usr/bin/perl
# vi: set ts=4:
$ARGV=shift @ARGV;
@output=`objdump -dr $ARGV`;
$obj=$ARGV;
$state=0;
while($_=shift @output){
chomp;
if(m/^\w+\.o:\s+file format.*/){
$obj = $_;
$obj =~ s/^(\w+\.o):\s+file format.*/\1/
}
if(m/^0[0-9a-fA-F]+\s<\w+>:$/){
$func = $_;
$func =~ s/^0[0-9a-fA-F]+\s<(\w+)>:$/\1/;
$addr = $_;
$addr =~ s/^(0[0-9a-fA-F]+)\s<\w+>:$/\1/;
if(@cfuncs){
@cfuncs = sort @cfuncs;
@last="";
foreach $f (@cfuncs) {
if($f ne $last){
if($f ne "::_GLOBAL_OFFSET_TABLE_"){
print " $f\n";
}
}
$last=$f;
}
}
@cfuncs=();
print "${obj}::$func:\n";
$state=0;
}
if(m/\scall\s/){
if(m/\scall\s.*<.*>/){
$cfunc = $_;
$cfunc =~ s/.*\scall\s.*<(.*)>$/\1/;
if($cfunc =~ m/$func\+0x/){
# wait for a reloc
$state=1;
}else{
push @cfuncs, "${obj}::$cfunc";
$state=0;
}
}else{
if($state==2){
push @cfuncs, "#$cfunc";
}else{
push @cfuncs, "#";
}
$state=0;
}
}
if(m/^\s+[0-9a-fA-F]+:\s\w+\s+\w+$/){
$cfunc = $_;
$cfunc =~ s/.*\s(\w+)$/\1/;
if($state==0){
# it just showed up. We might attach it to the next line.
$state=2;
}elsif($state==1){
# we're waiting for a reloc
push @cfuncs, "::$cfunc";
$state=0;
}
}
}
|