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

Bug#714191: [lintian] patch



Package: lintian
Version: 2.5.13
control: tag - 1 + patch

Fix this bug
From fb5a196f778988a6f96c7143f4e89067a70df965 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bastien=20ROUCARI=C3=88S?= <roucaries.bastien@gmail.com>
Date: Sun, 30 Jun 2013 18:34:16 +0200
Subject: [PATCH] Fix object file not checked if unstripped or with build-id
 debug or with compress debug section

Object files are not checked if:
- they have build-id debug file.
- they have compress debug section.
- they are not stripped.

Check this and add test.
---
 checks/binaries.pm                           |    4 ++--
 t/tests/binaries-general/debian/Makefile     |   13 +++++++++++
 t/tests/binaries-general/debian/debian/rules |    7 ++++++
 t/tests/binaries-general/debian/getbuildid   |   30 ++++++++++++++++++++++++++
 t/tests/binaries-general/desc                |    1 +
 t/tests/binaries-general/tags                |    8 ++++++-
 6 files changed, 60 insertions(+), 3 deletions(-)
 create mode 100755 t/tests/binaries-general/debian/debian/rules
 create mode 100755 t/tests/binaries-general/debian/getbuildid

diff --git a/checks/binaries.pm b/checks/binaries.pm
index 924ebc8..264183f 100644
--- a/checks/binaries.pm
+++ b/checks/binaries.pm
@@ -361,12 +361,12 @@ foreach my $file ($info->sorted_index) {
     }
 
     # Something other than detached debugging symbols in /usr/lib/debug paths.
-    if ($file =~ m,^usr/lib/debug/(?:lib\d*|s?bin|usr|opt|dev|emul)/,) {
+    if ($file =~ m,^usr/lib/debug/(?:lib\d*|s?bin|usr|opt|dev|emul|.build-id)/,) {
         if (scalar (@{ $objdump->{NEEDED} }) ) {
             tag 'debug-file-should-use-detached-symbols', $file;
         }
         tag 'debug-file-with-no-debug-symbols', $file
-            unless exists $objdump->{'SH'}->{'.debug_line'};
+            unless (exists $objdump->{'SH'}->{'.debug_line'} or exists $objdump->{'SH'}->{'.zdebug_line'});
     }
 
     # Detached debugging symbols directly in /usr/lib/debug.
diff --git a/t/tests/binaries-general/debian/Makefile b/t/tests/binaries-general/debian/Makefile
index 73446c0..82e951e 100644
--- a/t/tests/binaries-general/debian/Makefile
+++ b/t/tests/binaries-general/debian/Makefile
@@ -1,4 +1,6 @@
 COMPILE:= $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS)
+# extract from readelf
+GETBUILDID:=./getbuildid
 
 all:
 	# rpath not matching any of the exceptions to the rpath checks
@@ -10,6 +12,8 @@ all:
 	$(COMPILE) -o basicshippedrpath basic.c -Wl,--rpath,/usr/share/foo
 	# static version of basic for debugging checks
 	$(COMPILE) -static -o basic.static basic.c
+	# version with compressed debug
+	$(COMPILE) -o basiccompressdebug -g3 -Wl,--build-id -Wl,--compress-debug-sections=zlib basic.c
 
 install:
 	install -d $(DESTDIR)/usr/share/foo/
@@ -21,6 +25,15 @@ install:
 	install -m 755 -c basiclibrpath $(DESTDIR)/usr/lib/foo/basiclibrpath
 	install -m 755 -c basicshippedrpath $(DESTDIR)/usr/lib/foo/basicshippedrpath
 	objcopy --only-keep-debug basic $(DESTDIR)/usr/lib/debug/basic
+	install -d "$(DESTDIR)/usr/lib/debug/.build-id/"`$(GETBUILDID) -s basiccompressdebug`
+	install -m 755 -c basiccompressdebug $(DESTDIR)/usr/share/foo/basiccompressdebug
+	# force fake buildid in order to have tag matching ok (deadbeefdeadbeef)
+	install -d "$(DESTDIR)/usr/lib/debug/.build-id/de"
+	objcopy --compress-debug-sections basiccompressdebug \
+		"$(DESTDIR)/usr/lib/debug/.build-id/de/deadbeefdeadbeef.debug"
+	install -d "$(DESTDIR)/usr/lib/debug/.build-id/"`$(GETBUILDID) -s basiccompressdebug`
+	objcopy --compress-debug-sections --only-keep-debug basiccompressdebug \
+		"$(DESTDIR)/usr/lib/debug/.build-id/"`$(GETBUILDID) -s basiccompressdebug`"/"`$(GETBUILDID) -f basiccompressdebug`.debug
 	cp basic.static $(DESTDIR)/usr/lib/debug/
 	# dh_strip attempts to play the smart guy if the ELF obj is executable.
 	cd $(DESTDIR)/usr/lib/debug/ && chmod -x basic basic.static
diff --git a/t/tests/binaries-general/debian/debian/rules b/t/tests/binaries-general/debian/debian/rules
new file mode 100755
index 0000000..04d5d0b
--- /dev/null
+++ b/t/tests/binaries-general/debian/debian/rules
@@ -0,0 +1,7 @@
+#!/usr/bin/make -f
+
+DEB_BUILD_OPTIONS := nostrip
+export DEB_BUILD_OPTIONS
+
+%:
+	dh $@
diff --git a/t/tests/binaries-general/debian/getbuildid b/t/tests/binaries-general/debian/getbuildid
new file mode 100755
index 0000000..0dce67e
--- /dev/null
+++ b/t/tests/binaries-general/debian/getbuildid
@@ -0,0 +1,30 @@
+#!/bin/sh
+# get build-id of binary 
+
+set -e
+
+usage() {
+    echo "Usage: getbuildid [flag] file";
+    echo "       print build-id of an object file"
+    echo "flags:"
+    echo "  -f : full build-id (default)."
+    echo "  -s : short build-id aka the first two characters."
+}
+
+if test $# -lt 1; then usage; exit 77; fi;
+if test $# -gt 3; then usage; exit 77; fi;
+
+if test $# -eq 1; then
+ eu-readelf -n "$1" |  grep -i 'Build Id' | sed 's/.*:[[:blank:]]*\([[:digit:]|abcdef]*\).*/\1/g'
+else
+ case "x$1" in
+     'x-f')
+	eu-readelf -n "$2" |  grep -i 'Build Id' | sed 's/.*:[[:blank:]]*\([[:digit:]|abcdef]*\).*/\1/g' ;;
+     'x-s')
+	eu-readelf -n "$2" |  grep -i 'Build Id' | sed 's/.*:[[:blank:]]*\([[:digit:]|abcdef]\{2\}\).*/\1/g' ;;
+     *)
+	exit 2;
+ esac; 
+fi;
+
+exit 0;
\ No newline at end of file
diff --git a/t/tests/binaries-general/desc b/t/tests/binaries-general/desc
index 0c51bd7..c2202e8 100644
--- a/t/tests/binaries-general/desc
+++ b/t/tests/binaries-general/desc
@@ -10,3 +10,4 @@ Test-For:
  debug-symbols-directly-in-usr-lib-debug
  debug-file-with-no-debug-symbols
  library-in-debug-or-profile-should-not-be-stripped
+ unstripped-binary-or-object
diff --git a/t/tests/binaries-general/tags b/t/tests/binaries-general/tags
index e795381..17aacde 100644
--- a/t/tests/binaries-general/tags
+++ b/t/tests/binaries-general/tags
@@ -1,8 +1,14 @@
 E: binaries-general: arch-dependent-file-in-usr-share usr/share/foo/basic
+E: binaries-general: arch-dependent-file-in-usr-share usr/share/foo/basiccompressdebug
 E: binaries-general: binary-or-shlib-defines-rpath usr/lib/foo/basiclibrpath /usr/lib
 E: binaries-general: binary-or-shlib-defines-rpath usr/share/foo/basic /usr/local/lib
 E: binaries-general: debug-symbols-directly-in-usr-lib-debug usr/lib/debug/basic
 E: binaries-general: library-in-debug-or-profile-should-not-be-stripped usr/lib/debug/usr/share/foo/basic
+E: binaries-general: unstripped-binary-or-object usr/lib/foo/basiclibrpath
+E: binaries-general: unstripped-binary-or-object usr/lib/foo/basicshippedrpath
+E: binaries-general: unstripped-binary-or-object usr/share/foo/basic
+E: binaries-general: unstripped-binary-or-object usr/share/foo/basiccompressdebug
 W: binaries-general: binary-compiled-with-profiling-enabled usr/share/foo/basic
+W: binaries-general: debug-file-should-use-detached-symbols usr/lib/debug/.build-id/de/deadbeefdeadbeef.debug
 W: binaries-general: debug-file-with-no-debug-symbols usr/lib/debug/usr/share/foo/basic
-W: binaries-general: debug-package-should-be-named-dbg usr/lib/debug/basic
+W: binaries-general: debug-package-should-be-named-dbg usr/lib/debug/.build-id/
-- 
1.7.10.4


Reply to: