Prechádzať zdrojové kódy

Let dpkg-shlibdeps be smarter about missing symbols

dpkg-shlibdeps complains about missing symbols only for executables
(as defined by the ELF type) and public libraries (as defined by the
ELF type and the existence of a SONAME). This avoids many warnings
for perl modules and python modules.
Raphael Hertzog 19 rokov pred
rodič
commit
6e02b2ef46

+ 18 - 1
scripts/Dpkg/Shlibs/Objdump.pm

@@ -141,7 +141,7 @@ sub _read {
     $self->{file} = $file;
 
     local $ENV{LC_ALL} = 'C';
-    open(my $objdump, "-|", "objdump", "-w", "-p", "-T", $file)
+    open(my $objdump, "-|", "objdump", "-w", "-f", "-p", "-T", $file)
 	|| syserr(sprintf(_g("Can't execute objdump: %s"), $!));
     my $ret = $self->_parse($objdump);
     close($objdump);
@@ -190,6 +190,12 @@ sub _parse {
 	} elsif ($section eq "none") {
 	    if (/^\s*\S+:\s*file\s+format\s+(\S+)\s*$/) {
 		$self->{format} = $1;
+	    } elsif (/^architecture:\s*\S+,\s*flags:\s*\S+\s*$/) {
+		# Parse 2 lines of "-f"
+		# architecture: i386, flags 0x00000112:
+		# EXEC_P, HAS_SYMS, D_PAGED
+		# start address 0x08049b50
+		$self->{flags}{$_} = 1 foreach (split(/,\s*/, <$fh>));
 	    }
 	}
     }
@@ -314,4 +320,15 @@ sub get_needed_libraries {
     return @{$self->{NEEDED}};
 }
 
+sub is_executable {
+    my $self = shift;
+    return exists $self->{flags}{EXEC_P} and $self->{flags}{EXEC_P};
+}
+
+sub is_public_library {
+    my $self = shift;
+    return exists $self->{flags}{DYNAMIC} and $self->{flags}{DYNAMIC}
+	and exists $self->{SONAME} and $self->{SONAME};
+}
+
 1;

+ 10 - 6
scripts/dpkg-shlibdeps.pl

@@ -177,12 +177,16 @@ foreach my $file (keys %exec) {
 	} else {
 	    my $syminfo = $dumplibs_wo_symfile->locate_symbol($name);
 	    if (not defined($syminfo)) {
-		my $print_name = $name;
-		# Drop the default suffix for readability
-		$print_name =~ s/\@Base$//;
-		warning(sprintf(
-		    _g("symbol %s used by %s found in none of the libraries."),
-		    $print_name, $file)) unless $sym->{weak};
+		# Complain about missing symbols only for executables
+		# and public libraries
+		if ($obj->is_executable() or $obj->is_public_library()) {
+		    my $print_name = $name;
+		    # Drop the default suffix for readability
+		    $print_name =~ s/\@Base$//;
+		    warning(sprintf(
+			_g("symbol %s used by %s found in none of the libraries."),
+			$print_name, $file)) unless $sym->{weak};
+		}
 	    } else {
 		$used_sonames{$syminfo->{soname}}++;
 	    }

+ 3 - 0
scripts/t/200_Dpkg_Shlibs/objdump.glib-ia64

@@ -1,5 +1,8 @@
 
 /usr/lib/libglib-2.0.so.0:     file format elf64-little
+architecture: ia64-elf64, flags 0x00000150:
+HAS_SYMS, DYNAMIC, D_PAGED
+start address 0x000000000002dc40
 
 Program Header:
     LOAD off    0x0000000000000000 vaddr 0x0000000000000000 paddr 0x0000000000000000 align 2**16

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

@@ -1,5 +1,8 @@
 
 /lib/libc.so.6:     file format elf32-i386
+architecture: i386, flags 0x00000150:
+HAS_SYMS, DYNAMIC, D_PAGED
+start address 0x000161b0
 
 Program Header:
     PHDR off    0x00000034 vaddr 0x00000034 paddr 0x00000034 align 2**2

+ 3 - 0
scripts/t/200_Dpkg_Shlibs/objdump.libc6-2.6

@@ -1,5 +1,8 @@
 
 /lib/libc.so.6:     file format elf32-i386
+architecture: i386, flags 0x00000150:
+HAS_SYMS, DYNAMIC, D_PAGED
+start address 0x000161b0
 
 Program Header:
     PHDR off    0x00000034 vaddr 0x00000034 paddr 0x00000034 align 2**2