Bug#714191: [lintian] patch
On 2013-06-30 18:38, bastien ROUCARIES wrote:
> Package: lintian
> Version: 2.5.13
> control: tag - 1 + patch
>
> Fix this bug
>
Hi,
Thanks for the suggested patch.
I had to do an edit to make the test compile and I did a few other minor
stylistic changes. I do not quite see the fix for the "unstripped"
objects part - the only unstripped objects that appeared are caused by
the "nostrip" option to dh_strip and can trivially be "re-stripped" with
a dh_strip -X usr/lib/debug.
I have attached a patch based on yours (and the interdiff between this
version and your version for comparison).
~Niels
>From a51dd37467021dad0ac585272625f94c5d993b10 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] c/binaries: Improve check of debug ELF files
Fix object file not checked if installed in the ".build-id" dir or
with compressed debug section.
Signed-off-by: Niels Thykier <niels@thykier.net>
---
checks/binaries.pm | 5 +++--
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/tags | 4 +++-
5 files changed, 56 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..8eaf70f 100644
--- a/checks/binaries.pm
+++ b/checks/binaries.pm
@@ -361,12 +361,13 @@ 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..5086c0f 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 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..c60cf8b
--- /dev/null
+++ b/t/tests/binaries-general/debian/debian/rules
@@ -0,0 +1,7 @@
+#!/usr/bin/make -f
+
+%:
+ dh $@
+
+override_dh_strip:
+ dh_strip -X usr/lib/debug
diff --git a/t/tests/binaries-general/debian/getbuildid b/t/tests/binaries-general/debian/getbuildid
new file mode 100755
index 0000000..2706c69
--- /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;
diff --git a/t/tests/binaries-general/tags b/t/tests/binaries-general/tags
index e795381..1e5337d 100644
--- a/t/tests/binaries-general/tags
+++ b/t/tests/binaries-general/tags
@@ -1,8 +1,10 @@
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
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
diff -u b/checks/binaries.pm b/checks/binaries.pm
--- b/checks/binaries.pm
+++ b/checks/binaries.pm
@@ -366,7 +366,8 @@
tag 'debug-file-should-use-detached-symbols', $file;
}
tag 'debug-file-with-no-debug-symbols', $file
- unless (exists $objdump->{'SH'}->{'.debug_line'} or exists $objdump->{'SH'}->{'.zdebug_line'});
+ unless (exists $objdump->{'SH'}->{'.debug_line'}
+ or exists $objdump->{'SH'}->{'.zdebug_line'});
}
# Detached debugging symbols directly in /usr/lib/debug.
diff -u b/t/tests/binaries-general/debian/Makefile b/t/tests/binaries-general/debian/Makefile
--- b/t/tests/binaries-general/debian/Makefile
+++ b/t/tests/binaries-general/debian/Makefile
@@ -13,7 +13,7 @@
# 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
+ $(COMPILE) -o basiccompressdebug -g3 -Wl,--build-id basic.c
install:
install -d $(DESTDIR)/usr/share/foo/
diff -u b/t/tests/binaries-general/debian/debian/rules b/t/tests/binaries-general/debian/debian/rules
--- b/t/tests/binaries-general/debian/debian/rules
+++ b/t/tests/binaries-general/debian/debian/rules
@@ -3,5 +3,5 @@
-DEB_BUILD_OPTIONS := nostrip
-export DEB_BUILD_OPTIONS
-
%:
dh $@
+
+override_dh_strip:
+ dh_strip -X usr/lib/debug
diff -u b/t/tests/binaries-general/debian/getbuildid b/t/tests/binaries-general/debian/getbuildid
--- b/t/tests/binaries-general/debian/getbuildid
+++ b/t/tests/binaries-general/debian/getbuildid
@@ -1,5 +1,5 @@
#!/bin/sh
-# get build-id of binary
+# get build-id of binary
set -e
@@ -25,6 +25,6 @@
*)
exit 2;
- esac;
-fi;
+ esac
+fi
exit 0;
reverted:
--- b/t/tests/binaries-general/desc
+++ a/t/tests/binaries-general/desc
@@ -10,4 +10,3 @@
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 -u b/t/tests/binaries-general/tags b/t/tests/binaries-general/tags
--- b/t/tests/binaries-general/tags
+++ b/t/tests/binaries-general/tags
@@ -4,10 +4,6 @@
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
Reply to: