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

[PATCH] Don't dwz-compress file with compressed debug section



Hi,

When running dwz with an executable containing compressed debug sections we
get:
...
$ gcc -g ~/hello.c
$ objcopy --compress-debug-sections a.out
$ dwz a.out
dwz: a.out: DWARF version 0 unhandled
...

Fix this by emitting an appropriate error message:
...
dwz: a.out: Found compressed .debug_aranges section, not attempting dwz \
  compression
...

OK for trunk?

Thanks,
- Tom

Don't dwz-compress file with compressed debug section

2019-02-14  Tom de Vries  <tdevries@suse.de>

	PR dwz/24174
	* dwz.c (read_dwarf): Return 1 on finding compressed debug section.
	* testsuite/dwz.tests/pr24174.sh: New test.

---
 dwz.c                          |  8 ++++++++
 testsuite/dwz.tests/pr24174.sh | 18 ++++++++++++++++++
 2 files changed, 26 insertions(+)

diff --git a/dwz.c b/dwz.c
index d348418..4ef8657 100644
--- a/dwz.c
+++ b/dwz.c
@@ -9886,6 +9886,14 @@ read_dwarf (DSO *dso, bool quieter)
 	    || strcmp (name, ".gdb_index") == 0
 	    || strcmp (name, ".gnu_debugaltlink") == 0)
 	  {
+	    if (dso->shdr[i].sh_flags & SHF_COMPRESSED)
+	      {
+		error (0, 0,
+		       "%s: Found compressed %s section, not attempting dwz"
+		       " compression",
+		       dso->filename, name);
+		return 1;
+	      }
 	    for (j = 0; debug_sections[j].name; ++j)
 	      if (strcmp (name, debug_sections[j].name) == 0)
 		{
diff --git a/testsuite/dwz.tests/pr24174.sh b/testsuite/dwz.tests/pr24174.sh
new file mode 100755
index 0000000..e522b06
--- /dev/null
+++ b/testsuite/dwz.tests/pr24174.sh
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+set -e
+
+cp ../hello 1
+objcopy --compress-debug-sections 1
+if dwz 1 2>dwz.err; status=$?; then
+   true
+fi
+
+grep "DWARF version 0 unhandled" dwz.err || true
+rm -f dwz.err
+
+[ $status -eq 1 ]
+
+[ $(ls) = "1" ]
+
+rm -f 1