From 6e02b2ef46aadde5ce142bb42b58e3165253eb58 Mon Sep 17 00:00:00 2001 From: Raphael Hertzog Date: Mon, 24 Sep 2007 17:26:24 +0200 Subject: [PATCH] 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. --- scripts/Dpkg/Shlibs/Objdump.pm | 19 ++++++++++++++++++- scripts/dpkg-shlibdeps.pl | 16 ++++++++++------ scripts/t/200_Dpkg_Shlibs/objdump.glib-ia64 | 3 +++ scripts/t/200_Dpkg_Shlibs/objdump.libc6-2.3 | 3 +++ scripts/t/200_Dpkg_Shlibs/objdump.libc6-2.6 | 3 +++ 5 files changed, 37 insertions(+), 7 deletions(-) diff --git a/scripts/Dpkg/Shlibs/Objdump.pm b/scripts/Dpkg/Shlibs/Objdump.pm index 9d690702..e08699df 100644 --- a/scripts/Dpkg/Shlibs/Objdump.pm +++ b/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; diff --git a/scripts/dpkg-shlibdeps.pl b/scripts/dpkg-shlibdeps.pl index f3117e24..e1f791b3 100755 --- a/scripts/dpkg-shlibdeps.pl +++ b/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}}++; } diff --git a/scripts/t/200_Dpkg_Shlibs/objdump.glib-ia64 b/scripts/t/200_Dpkg_Shlibs/objdump.glib-ia64 index 1b3d9871..a3ff4d8b 100644 --- a/scripts/t/200_Dpkg_Shlibs/objdump.glib-ia64 +++ b/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 diff --git a/scripts/t/200_Dpkg_Shlibs/objdump.libc6-2.3 b/scripts/t/200_Dpkg_Shlibs/objdump.libc6-2.3 index 2eb8ae34..e7610510 100644 --- a/scripts/t/200_Dpkg_Shlibs/objdump.libc6-2.3 +++ b/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 diff --git a/scripts/t/200_Dpkg_Shlibs/objdump.libc6-2.6 b/scripts/t/200_Dpkg_Shlibs/objdump.libc6-2.6 index 7efee24a..ba68d1c9 100644 --- a/scripts/t/200_Dpkg_Shlibs/objdump.libc6-2.6 +++ b/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 -- 2.39.5