Просмотр исходного кода

Blacklist useless internal symbols in SymbolFile

Some external symbols are never used by the applications. They are only
used by the "internal machinery" and create spurious architecture-specific
differences in the symbols files. Thus it's best if we explicitely ignore
them.
Raphael Hertzog лет назад: 19
Родитель
Сommit
a1f219403f

+ 40 - 1
scripts/Dpkg/Shlibs/SymbolFile.pm

@@ -21,6 +21,39 @@ use Dpkg::ErrorHandling qw(syserr warning error);
 use Dpkg::Version qw(vercmp);
 textdomain("dpkg-dev");
 
+my %blacklist = (
+    '__bss_end__' => 1,		# arm
+    '__bss_end' => 1,		# arm
+    '_bss_end__' => 1,		# arm
+    '__bss_start' => 1,		# ALL
+    '__bss_start__' => 1,	# arm
+    '__data_start' => 1,	# arm
+    '__do_global_ctors_aux' => 1,   # ia64
+    '__do_global_dtors_aux' => 1,   # ia64
+    '__do_jv_register_classes' => 1,# ia64
+    '_edata' => 1,		# ALL
+    '_end' => 1,		# ALL
+    '__end__' => 1,		# arm
+    '_fbss' => 1,		# mips, mipsel
+    '_fdata' => 1,		# mips, mipsel
+    '_fini' => 1,		# ALL
+    '_ftext' => 1,		# mips, mipsel
+    '_GLOBAL_OFFSET_TABLE_' => 1,   # hppa, mips, mipsel
+    '__gmon_start__' => 1,	# hppa
+    '_gp' => 1,			# mips, mipsel
+    '_init' => 1,		# ALL
+);
+
+for (my $i = 14; $i <= 31; $i++) {
+    # Many powerpc specific symbols
+    $blacklist{"_restfpr_$i"} = 1;
+    $blacklist{"_restfpr_$i\_x"} = 1;
+    $blacklist{"_restgpr_$i"} = 1;
+    $blacklist{"_restgpr_$i\_x"} = 1;
+    $blacklist{"_savefpr_$i"} = 1;
+    $blacklist{"_savegpr_$i"} = 1;
+}
+
 sub new {
     my $this = shift;
     my $file = shift;
@@ -144,12 +177,18 @@ sub dump {
 
 # merge_symbols($object, $minver)
 # Needs $Objdump->get_object($soname) as parameter
+# Don't merge blacklisted symbols related to the internal (arch-specific)
+# machinery
 sub merge_symbols {
     my ($self, $object, $minver) = @_;
     my $soname = $object->{SONAME} || error(_g("Can't merge symbols from objects without SONAME."));
     my %dynsyms = map { $_ => $object->{dynsyms}{$_} }
-	grep { local $a = $object->{dynsyms}{$_}; $a->{dynamic} && $a->{defined} }
+	grep { 
+	    local $a = $object->{dynsyms}{$_}; 
+	    $a->{dynamic} && $a->{defined} && not exists $blacklist{$a->{name}}
+	}
 	keys %{$object->{dynsyms}};
+
     unless ($self->{objects}{$soname}) {
 	$self->create_object($soname, '');
     }

+ 5 - 1
scripts/t/200_Dpkg_Shlibs.t

@@ -1,6 +1,6 @@
 # -*- mode: cperl;-*-
 
-use Test::More tests => 23;
+use Test::More tests => 24;
 
 use strict;
 use warnings;
@@ -74,6 +74,10 @@ $sym_file->merge_symbols($obj, "2.6-1");
 ok( $sym_file->has_new_symbols($sym_file_old), 'has new symbols' );
 ok( $sym_file_old->has_lost_symbols($sym_file), 'has lost symbols' );
 
+is( $sym_file_old->lookup_symbol('__bss_start@Base', ['libc.so.6']),
+    undef, 'internal symbols are blacklisted');
+
+
 use File::Temp;
 
 my $save_file = new File::Temp;

+ 1 - 0
scripts/t/200_Dpkg_Shlibs/objdump.libc6-2.3

@@ -104,6 +104,7 @@ DYNAMIC SYMBOL TABLE:
 00115360 l    d  .data.rel.ro	00000000              .data.rel.ro
 00117060 l    d  .data	00000000              .data
 00117f20 l    d  .bss	00000000              .bss
+000036fc g    D  *ABS*	00000000  Base        __bss_start
 00056ef0 g    DF .text	000000db  GLIBC_2.2   getwchar
 0002c1e0  w   DF .text	00000049  GLIBC_2.0   seed48_r
 000e3fc0 g    DF .text	00000068  GLIBC_2.0   xdr_cryptkeyres