[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[lintian] 02/02: objdump-info-helper: Fix readelf parsing bug



This is an automated email from the git hooks/post-receive script.

nthykier pushed a commit to branch master
in repository lintian.

commit 3c561c4f4ea114880c822a5cd503c7100b381d95
Author: Niels Thykier <niels@thykier.net>
Date:   Sat Jun 20 11:19:12 2015 +0200

    objdump-info-helper: Fix readelf parsing bug
    
    Fix a bug where lintian would ignore up to 10 named sections.  The
    problem was that readelf generated:
    
      [ 9] .comment
    
    But we basically matched for:
    
      \[\d+\] \S+
    
    Which meant the leading space caused us to ignore a valid section.
    
    Signed-off-by: Niels Thykier <niels@thykier.net>
---
 debian/changelog                              |  2 ++
 helpers/coll/objdump-info-helper              |  7 ++-----
 t/tests/binaries-static-lib/tags              |  1 +
 t/tests/binaries-static-lib/upstream/Makefile | 16 ++++++++++++++--
 4 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index dd98553..dfc0bd4 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -146,6 +146,8 @@ lintian (2.5.32) UNRELEASED; urgency=medium
 
   * helpers/coll/objdump-info-helper:
     + [NT] Collect readelf output from static libraries.
+    + [NT] Fix bug that caused lintian to ignore the up to 10
+      valid named sections.
 
   * lib/Lintian/Check.pm:
     + [NT] Rewrite check_spelling{,_picky} with a new interface,
diff --git a/helpers/coll/objdump-info-helper b/helpers/coll/objdump-info-helper
index dc7444f..3d35fbf 100755
--- a/helpers/coll/objdump-info-helper
+++ b/helpers/coll/objdump-info-helper
@@ -173,11 +173,8 @@ while (my $line = <$readelf>) {
         redo if $redo;
         next;
 
-    } elsif ($line =~ m/^\s*\[(\d+)\]\s*(\S+)(?:\s|\Z)/
-        and $section eq 'SH') {
-        # We also match " [<addr>]: flags*, but don't need them
-        # - in this case $2 will be ':'.
-        next if $2 eq ':';
+    } elsif ($line =~ m/^\s*\[\s*(\d+)\] (\S+)(?:\s|\Z)/
+             and $section eq 'SH') {
         $sections[$1] = $2;
         # We need sections as well (e.g. for incomplete stripping)
         print " $1 $2\n";
diff --git a/t/tests/binaries-static-lib/tags b/t/tests/binaries-static-lib/tags
index efbedb5..abea104 100644
--- a/t/tests/binaries-static-lib/tags
+++ b/t/tests/binaries-static-lib/tags
@@ -1,2 +1,3 @@
+I: libfoo-dev: binary-has-unneeded-section usr/lib/libbar.a(pstripped.o) .comment
 I: libfoo-dev: binary-has-unneeded-section usr/lib/libfoo.a(code.o) .comment
 I: libfoo-dev: binary-has-unneeded-section usr/lib/libfoo.a(other.o) .comment
diff --git a/t/tests/binaries-static-lib/upstream/Makefile b/t/tests/binaries-static-lib/upstream/Makefile
index b75ce96..0fb8239 100644
--- a/t/tests/binaries-static-lib/upstream/Makefile
+++ b/t/tests/binaries-static-lib/upstream/Makefile
@@ -1,10 +1,22 @@
 CC=gcc
 CFLAGS+= -g
-LIBFILES:= libfoo.a
+LIBFILES:= libfoo.a libbar.a
 
 all: $(LIBFILES)
 
-$(LIBFILES): code.o other.o
+libfoo.a: code.o other.o
+	ar rcs -o $@ $^
+
+pstripped.o: other.o
+	cp other.o pstripped.o
+	strip --strip-debug pstripped.o
+
+fstripped.o: other.o
+	cp other.o fstripped.o
+	strip --strip-debug --remove-section=.comment \
+	    --remove-section=.note fstripped.o
+
+libbar.a: fstripped.o pstripped.o
 	ar rcs -o $@ $^
 
 clean:

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/lintian/lintian.git


Reply to: