Cmpsymtbl.pl: Unterschied zwischen den Versionen

aus Metalab, dem offenen Zentrum für meta-disziplinäre Magier und technisch-kreative Enthusiasten.
Wechseln zu: Navigation, Suche
 
(2 dazwischenliegende Versionen von 2 Benutzern werden nicht angezeigt)
Zeile 54: Zeile 54:
 
print "latter missing $missinginfile2 with $matches matching\n";
 
print "latter missing $missinginfile2 with $matches matching\n";
 
</pre>
 
</pre>
 +
 +
[[Kategorie:Howto]]

Aktuelle Version vom 27. Januar 2013, 06:25 Uhr

Script to compare the symbol tables of two objects and show missing symbols from the second. Example execution:

./symbtblcmp.pl objdump tpsession/tpsession-0.1/tpsession/libtpsession.so.0.1.0 \
   ~/nokiaqtsdk/Maemo/4.6.2/targets/fremantle-1030/bin/objdump \
   ~/nokiaqtsdk/Maemo/4.6.2/sysroots/fremantle-arm-sysroot-1030-slim/usr/lib/libtpsession.so.0.1.0

cmpsymtbl.pl

#!/usr/bin/perl

if ($#ARGV < 3) {
    print "USAGE:\n\t$. <objdump1_path> <master_obj> <objdump2_path> <cmp_object>\n\n"
}

my $objdump1 = $ARGV[0];
my $file1 = $ARGV[1];
my $objdump2 = $ARGV[2];
my $file2 = $ARGV[3];

my $matches = 0;
my $missinginfile2 = 0;

my %symtbl2 = ();
foreach my $line (`$objdump2 -t $file2`) {
	if ($line =~ m/^[0-9A-Fa-f]{8}.*\s(\S+)$/) {
		#print ".";
		$symtbl2{"$1"} = 0;
	}
}

my %symtbl1 = ();
my $count = 0;
foreach my $line (`$objdump1 -t $file1`) {
	if ($line =~ m/^[0-9A-Fa-f]{8}.*\s(\S+)$/) {
		if (exists $symtbl1{"$1"}) { next }; # handle duplicate entries
		$symtbl1{"$1"} = 0;
		if (exists $symtbl2{"$1"}) {
			$matches++;
		}
		else {
			$missinginfile2++;
			print "missing $1\n";
		}
	}
}
print "\n";

print `file $file1`;
print `file $file2`, "\n";
print scalar keys %symtbl1, " in $file1\n";
print scalar keys %symtbl2, " in $file2\n";
print "latter missing $missinginfile2 with $matches matching\n";