- if ($locs{$prog} ne "") {
- $searchaddr = sprintf "%#x", $addr - $locs{$prog};
- } else {
- $searchaddr = $addr;
- $prog = $binary;
- }
- if ($binary ne "" && open (ADDR, "addr2line -e $prog $searchaddr|")) {
- my $line = <ADDR>;
- chomp $line;
- close (ADDR);
- if ($line ne '??:0') {
- $cache{$addr} = $line;
- return $cache{$addr};
+ $searchaddr = sprintf "%#x", hex($addr) + $rel{$prog};
+ if ($binary ne "") {
+ for my $address ($searchaddr, $addr) {
+ my $line = &addr2line($prog, $address);
+ if ($line) {
+ $cache{$addr} = $line;
+ return $cache{$addr};
+ }