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

[lintian] 01/01: c/binaries: Detect completely unstripped static libs



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

nthykier pushed a commit to branch master
in repository lintian.

commit e5a06baca1f9a46ad37386c6570ddd2ee591cf56
Author: Niels Thykier <niels@thykier.net>
Date:   Tue Jul 21 20:02:06 2015 +0200

    c/binaries: Detect completely unstripped static libs
    
    Signed-off-by: Niels Thykier <niels@thykier.net>
---
 checks/binaries.desc                          | 12 +++++++++---
 checks/binaries.pm                            | 20 ++++++++++++++++----
 debian/changelog                              |  5 +++--
 t/tests/binaries-static-lib/desc              |  4 +++-
 t/tests/binaries-static-lib/tags              |  4 ++--
 t/tests/binaries-static-lib/upstream/Makefile |  4 ++--
 6 files changed, 35 insertions(+), 14 deletions(-)

diff --git a/checks/binaries.desc b/checks/binaries.desc
index db99863..85e2355 100644
--- a/checks/binaries.desc
+++ b/checks/binaries.desc
@@ -103,9 +103,15 @@ Certainty: certain
 Experimental: yes
 Info: Tag for tallying static libraries ".comment" sections.
  .
- Be advised that some languages (e.g. OCaml) store bytecode in the
- ".comment" section and you should therefore <i>not</i> blindly
- strip this section.
+ Note that debhelper does not correctly strip these at the moment.
+ If you use debhelper to strip the library, please ignore this tag
+ at the moment.
+
+Tag: unstripped-static-library
+Severity: wishlist
+Certainty: certain
+Experimental: yes
+Info: Tag for tallying unstripped static libraries.
 
 Tag: missing-depends-line
 Severity: normal
diff --git a/checks/binaries.pm b/checks/binaries.pm
index 6f4ed63..29ebf89 100644
--- a/checks/binaries.pm
+++ b/checks/binaries.pm
@@ -27,6 +27,15 @@ use autodie;
 use constant NUMPY_STRING => 'module compiled against ABI version %x'
   . ' but this version of numpy is %x';
 
+# These are the ones file(1) looks for.  The ".zdebug_info" being the
+# compressed version of .debug_info.
+# - Technically, file(1) also looks for .symtab, but that is apparently
+#   not strippable for static libs.  Accordingly, it is omitted below.
+use constant DEBUG_SECTIONS => qw(.debug_info .zdebug_info);
+
+use File::Spec;
+use List::MoreUtils qw(any);
+
 use Lintian::Check qw(check_spelling spelling_tag_emitter);
 use Lintian::Data;
 use Lintian::Relation qw(:constants);
@@ -34,8 +43,6 @@ use Lintian::Tags qw(tag);
 use Lintian::Output qw(debug_msg);
 use Lintian::Util qw(fail slurp_entire_file strip);
 
-use File::Spec;
-
 my $ARCH_REGEX = Lintian::Data->new('binaries/arch-regex', qr/\s*\~\~/o,
     sub { return qr/$_[1]/ });
 my $ARCH_64BIT_EQUIVS
@@ -306,8 +313,13 @@ sub run {
                 # Shouldn't happen, but...
                 fail("object ($file $obj) in static lib is missing!?")
                   unless defined $libobj;
-                tag_unneeded_sections('static-library-has-unneeded-section',
-                    "${file}(${obj})", $libobj);
+
+                if (any { exists($libobj->{'SH'}{$_}) } DEBUG_SECTIONS) {
+                    tag 'unstripped-static-library', "${file}(${obj})";
+                } else {
+                    tag_unneeded_sections('static-library-has-unneeded-section',
+                                          "${file}(${obj})", $libobj);
+                }
             }
         }
 
diff --git a/debian/changelog b/debian/changelog
index 7c68d00..691e7a7 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,15 +2,16 @@ lintian (2.5.34) UNRELEASED; urgency=medium
 
   XXX: generate tag summary
 
-  * checks/binaries.desc:
+  * checks/binaries.{desc,pm}:
     + [NT] Apply patch from Guillem Jover to improve the tag
       description of the LFS tag.  (Closes: #792167)
+    + [NT] Detect unstripped static libraries (as an
+      experimental tag).
   * checks/cruft.pm:
     + [NT] Avoid svn-conflict-file tag for ".r0" files, since
       there cannot be a conflict involving revision 0.
       Thanks to Andreas Beckmann for the report.
       (Closes: #793068)
-
   * checks/systemd.pm:
     + [NT] Apply patches from Felipe Sateler to ignore known
       masked init.d scripts.  (Closes: #792501)
diff --git a/t/tests/binaries-static-lib/desc b/t/tests/binaries-static-lib/desc
index 0e4ed29..111e092 100644
--- a/t/tests/binaries-static-lib/desc
+++ b/t/tests/binaries-static-lib/desc
@@ -3,4 +3,6 @@ Sequence: 6000
 Version: 1.0-1
 Type: non-native
 Description: Test checks related to static libs
-Test-For: static-library-has-unneeded-section
+Test-For:
+ static-library-has-unneeded-section
+ unstripped-static-library
diff --git a/t/tests/binaries-static-lib/tags b/t/tests/binaries-static-lib/tags
index 85c413f..7b56728 100644
--- a/t/tests/binaries-static-lib/tags
+++ b/t/tests/binaries-static-lib/tags
@@ -1,3 +1,3 @@
 X: libfoo-dev: static-library-has-unneeded-section usr/lib/libbar.a(pstripped.o) .comment
-X: libfoo-dev: static-library-has-unneeded-section usr/lib/libfoo.a(code.o) .comment
-X: libfoo-dev: static-library-has-unneeded-section usr/lib/libfoo.a(other.o) .comment
+X: libfoo-dev: unstripped-static-library usr/lib/libfoo.a(code.o)
+X: libfoo-dev: unstripped-static-library usr/lib/libfoo.a(other.o)
diff --git a/t/tests/binaries-static-lib/upstream/Makefile b/t/tests/binaries-static-lib/upstream/Makefile
index 0fb8239..c6d2401 100644
--- a/t/tests/binaries-static-lib/upstream/Makefile
+++ b/t/tests/binaries-static-lib/upstream/Makefile
@@ -9,11 +9,11 @@ libfoo.a: code.o other.o
 
 pstripped.o: other.o
 	cp other.o pstripped.o
-	strip --strip-debug pstripped.o
+	strip --strip-unneeded pstripped.o
 
 fstripped.o: other.o
 	cp other.o fstripped.o
-	strip --strip-debug --remove-section=.comment \
+	strip --strip-unneeded --remove-section=.comment \
 	    --remove-section=.note fstripped.o
 
 libbar.a: fstripped.o pstripped.o

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


Reply to: