Use vmaddr for __TEXT section, not first section, so that we get correct results for the binary.

This commit is contained in:
dbaron%dbaron.org 2007-08-14 04:44:33 +00:00
Родитель b9f9cb3abe
Коммит d439557679
1 изменённых файлов: 11 добавлений и 5 удалений

Просмотреть файл

@ -36,7 +36,7 @@
#
# ***** END LICENSE BLOCK *****
# $Id: fix-macosx-stack.pl,v 1.3 2007-08-14 04:35:29 dbaron%dbaron.org Exp $
# $Id: fix-macosx-stack.pl,v 1.4 2007-08-14 04:44:33 dbaron%dbaron.org Exp $
#
# This script processes the output of nsTraceRefcnt's Mac OS X stack
# walking code. This is useful for two things:
@ -61,17 +61,23 @@ my %address_adjustments;
sub address_adjustment($) {
my ($file) = @_;
unless (exists $address_adjustments{$file}) {
my $result = 0;
my $result = -1;
open(OTOOL, '-|', 'otool', '-l', $file);
while (<OTOOL>) {
if (/^ vmaddr (0x[0-9a-f]{8})$/) {
$result = hex($1);
last;
if (/^ segname __TEXT$/) {
if (<OTOOL> =~ /^ vmaddr (0x[0-9a-f]{8})$/) {
$result = hex($1);
last;
} else {
die "Bad output from otool";
}
}
}
close(OTOOL);
$result >= 0 || die "Bad output from otool";
$address_adjustments{$file} = $result;
}