[PATCH] libdw, readelf: Handle GCC LTO .gnu.debuglto_ prefix.
GCC puts (partial) DWARF debuginfo into sections prefixed with .gnu.debuglto_. Handle those sections as if they are normal .debug sections (which they are). This allows showing the DWARF that gcc puts into ET_REL files compiled with -flto. Signed-off-by: Mark Wielaard --- libdw/ChangeLog | 4 libdw/dwarf_begin_elf.c | 4 libebl/ChangeLog| 5 + libebl/eblopenbackend.c | 4 +++- src/ChangeLog | 4 src/readelf.c | 9 +++-- 6 files changed, 27 insertions(+), 3 deletions(-) diff --git a/libdw/ChangeLog b/libdw/ChangeLog index 59f33f9e..39730fbc 100644 --- a/libdw/ChangeLog +++ b/libdw/ChangeLog @@ -1,3 +1,7 @@ +2020-04-17 Mark Wielaard + + * dwarf_begin_elf.c (check_section): Handle .gnu.debuglto_ prefix. + 2019-10-28 Aaron Merey * Makefile.am (libdw_so_LDLIBS): Add -ldl for libdebuginfod.so dlopen. diff --git a/libdw/dwarf_begin_elf.c b/libdw/dwarf_begin_elf.c index 85343088..474ed138 100644 --- a/libdw/dwarf_begin_elf.c +++ b/libdw/dwarf_begin_elf.c @@ -137,6 +137,10 @@ check_section (Dwarf *result, size_t shstrndx, Elf_Scn *scn, bool inscngrp) gnu_compressed = true; break; } + else if (scnlen > 14 /* .gnu.debuglto_ prefix. */ + && strncmp (scnname, ".gnu.debuglto_", 14) == 0 + && strcmp (&scnname[14], dwarf_scnnames[cnt]) == 0) + break; } if (cnt >= ndwarf_scnnames) diff --git a/libebl/ChangeLog b/libebl/ChangeLog index b3287310..90cf9728 100644 --- a/libebl/ChangeLog +++ b/libebl/ChangeLog @@ -1,3 +1,8 @@ +2020-04-17 Mark Wielaard + + * eblopenbackend.c (default_debugscn_p): Handle .gnu.debuglto_ + prefix. + 2020-02-08 Mark Wielaard * eblsegmenttypename.c (ebl_segment_type_name): Handle diff --git a/libebl/eblopenbackend.c b/libebl/eblopenbackend.c index 210b47e8..4ebde45f 100644 --- a/libebl/eblopenbackend.c +++ b/libebl/eblopenbackend.c @@ -621,7 +621,9 @@ default_debugscn_p (const char *name) for (size_t cnt = 0; cnt < ndwarf_scn_names; ++cnt) if (strcmp (name, dwarf_scn_names[cnt]) == 0 || (strncmp (name, ".zdebug", strlen (".zdebug")) == 0 - && strcmp (&name[2], &dwarf_scn_names[cnt][1]) == 0)) + && strcmp (&name[2], &dwarf_scn_names[cnt][1]) == 0) + || (strncmp (name, ".gnu.debuglto_", strlen (".gnu.debuglto_")) == 0 + && strcmp (&name[14], dwarf_scn_names[cnt]) == 0)) return true; return false; diff --git a/src/ChangeLog b/src/ChangeLog index e11fe79a..5d2d4254 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2020-04-17 Mark Wielaard + + * readelf.c (print_debug): Check .gnu.debuglto_ prefix. + 2020-02-08 Mark Wielaard * elflint.c (check_program_header): Handle PT_GNU_PROPERTY. diff --git a/src/readelf.c b/src/readelf.c index cbb519d1..685d0b17 100644 --- a/src/readelf.c +++ b/src/readelf.c @@ -11253,7 +11253,8 @@ print_debug (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr) if (strcmp (name, ".debug_info") == 0 || strcmp (name, ".debug_info.dwo") == 0 || strcmp (name, ".zdebug_info") == 0 - || strcmp (name, ".zdebug_info.dwo") == 0) + || strcmp (name, ".zdebug_info.dwo") == 0 + || strcmp (name, ".gnu.debuglto_.debug_info") == 0) { print_debug_info_section (dwflmod, ebl, ehdr, scn, shdr, dbg); @@ -11339,7 +11340,11 @@ print_debug (Dwfl_Module *dwflmod, Ebl *ebl, GElf_Ehdr *ehdr) dbglen - 1) == 0 && (scnlen == dbglen + 1 || (scnlen == dbglen + 5 - && strstr (name, ".dwo") == name + dbglen + 1 + && strstr (name, ".dwo") == name + dbglen + 1))) + || (scnlen > 14 /* .gnu.debuglto_ prefix. */ + && strncmp (name, ".gnu.debuglto_", 14) == 0 + && strcmp (&name[14], debug_sections[n].name) == 0) +) { if ((print_debug_sections | implicit_debug_sections) & debug_sections[n].bitmask) -- 2.18.2
[Bug general/24498] 0.176: isn't LTO ready
https://sourceware.org/bugzilla/show_bug.cgi?id=24498 --- Comment #17 from Mark Wielaard --- (In reply to Mark Wielaard from comment #16) > Various self tests fail when everything is build with LTO. > [...] > Another issue is that ET_REL files don't contain normal DWARF .debug_ > sections, but .gnu.debuglto_.debug_* sections. Which libdw doesn't > recognize. Still working on that. Patch to handle those posted: https://sourceware.org/pipermail/elfutils-devel/2020q2/002627.html With this and the SHF_EXCLUDE patch there are only 2 more test failures, test-nlist and run-varlocs-self.sh, which look like they can be solved by be a bit more careful what to check (test-nlist relies on symbols being in the source file declared order, run-varlocs-self.sh relies on ET_REL debuginfo containing addresses). -- You are receiving this mail because: You are on the CC list for the bug.
[PATCH] tests: Build test-nlist with minimal CFLAGS to guarantee symbol order.
test_nlist checks its own symbol table, and expects various symbols to be in the order as specified in the source file. Explicitly set minimal CFLAGS. Signed-off-by: Mark Wielaard --- tests/ChangeLog | 5 + tests/Makefile.am | 9 + 2 files changed, 14 insertions(+) diff --git a/tests/ChangeLog b/tests/ChangeLog index 96e0642a..886a3efb 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,8 @@ +2020-04-17 Mark Wielaard + + * Makefile.am (test-nlist$): New goal with minimal CFLAGS. + (test_nlist_CFLAGS): New variable. + 2020-03-28 Frank Ch. Eigler * run-debuginfod-find.sh: Test timestamps of archive-origin files. diff --git a/tests/Makefile.am b/tests/Makefile.am index 40b1c001..d173d547 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -80,6 +80,14 @@ backtrace-child-biarch$(EXEEXT): backtrace-child.c $(AM_LDFLAGS) $(LDFLAGS) $(backtrace_child_LDFLAGS) \ -o $@ $< +# test_nlist checks its own symbol table, and expects various symbols +# to be in the order as specified in the source file. Explicitly set +# minimal CFLAGS +test-nlist$(EXEEXT): test-nlist.c + $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(test_nlist_CFLAGS) $(test_nlist_LDADD) -o $@ $< + TESTS = run-arextract.sh run-arsymtest.sh run-ar.sh newfile test-nlist \ update1 update2 update3 update4 \ run-show-die-info.sh run-get-files.sh run-get-lines.sh \ @@ -557,6 +565,7 @@ scnnames_LDADD = $(libelf) sectiondump_LDADD = $(libelf) showptable_LDADD = $(libelf) hash_LDADD = $(libelf) +test_nlist_CFLAGS =-g -O0 test_nlist_LDADD = $(libelf) msg_tst_LDADD = $(libelf) newscn_LDADD = $(libelf) -- 2.18.2
[PATCH] tests: Run run-varlocs-self.sh for object files with --exprlocs.
The varlocs test relies on finding addresses for the CUs, even in object files. This might not be true (for example when building with gcc -flto, which only emits partial, type only, debuginfo). Split running the self tests in running on executables and shared libraries as normal, but run object files with --exprlocs to test that output too (and not require addresses). Signed-off-by: Mark Wielaard --- tests/ChangeLog | 7 +++ tests/run-varlocs-self.sh | 4 +++- tests/test-subr.sh| 13 + 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/tests/ChangeLog b/tests/ChangeLog index 886a3efb..301b0fb6 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,10 @@ +2020-04-17 Mark Wielaard + + * test-subr.sh (testrun_on_self_obj): New function. + * run-varlocs-self.sh: Run testrun_on_self_exe and + testrun_on_self_lib with -e, run testrun_on_self_obj with + --exprlocs -e. + 2020-04-17 Mark Wielaard * Makefile.am (test-nlist$): New goal with minimal CFLAGS. diff --git a/tests/run-varlocs-self.sh b/tests/run-varlocs-self.sh index 54b6a8d7..5454fc70 100755 --- a/tests/run-varlocs-self.sh +++ b/tests/run-varlocs-self.sh @@ -19,4 +19,6 @@ # Make sure varlocs doesn't crash, doesn't trigger self-check/asserts # or leaks running under valgrind. -testrun_on_self_quiet ${abs_top_builddir}/tests/varlocs -e +testrun_on_self_exe ${abs_top_builddir}/tests/varlocs -e +testrun_on_self_lib ${abs_top_builddir}/tests/varlocs -e +testrun_on_self_obj ${abs_top_builddir}/tests/varlocs --exprlocs -e diff --git a/tests/test-subr.sh b/tests/test-subr.sh index e768c1e5..411e5f28 100644 --- a/tests/test-subr.sh +++ b/tests/test-subr.sh @@ -168,6 +168,19 @@ testrun_on_self_lib() if test $exit_status != 0; then exit $exit_status; fi } +testrun_on_self_obj() +{ + exit_status=0 + + for file in $self_test_files_obj; do + testrun $* $file \ + || { echo "*** failure in $* $file"; exit_status=1; } + done + + # Only exit if something failed + if test $exit_status != 0; then exit $exit_status; fi +} + # Compress the files first. Compress both debug sections and symtab. testrun_on_self_compressed() { -- 2.18.2
[Bug general/24498] 0.176: isn't LTO ready
https://sourceware.org/bugzilla/show_bug.cgi?id=24498 --- Comment #18 from Mark Wielaard --- (In reply to Mark Wielaard from comment #17) > With this and the SHF_EXCLUDE patch there are only 2 more test failures, > test-nlist and run-varlocs-self.sh, which look like they can be solved by be > a bit more careful what to check (test-nlist relies on symbols being in the > source file declared order, run-varlocs-self.sh relies on ET_REL debuginfo > containing addresses). Patches for both issues have been posted: https://sourceware.org/pipermail/elfutils-devel/2020q2/002629.html https://sourceware.org/pipermail/elfutils-devel/2020q2/002630.html -- You are receiving this mail because: You are on the CC list for the bug.
[Bug tools/23787] eu-size: Bad handling of ar files inside are files
https://sourceware.org/bugzilla/show_bug.cgi?id=23787 Martinking changed: What|Removed |Added CC||ijaffery7 at gmail dot com --- Comment #23 from Martinking --- What If I tell you that I have written brief about these files. https://besticious.com/best-laptops-for-nursing-students/ -- You are receiving this mail because: You are on the CC list for the bug.
[Bug general/25838] eu-readelf crashes due to a general protection fault
https://sourceware.org/bugzilla/show_bug.cgi?id=25838 Mark Wielaard changed: What|Removed |Added CC||mark at klomp dot org --- Comment #1 from Mark Wielaard --- Sorry, I cannot replicate this on either x86_64 or i686. Running the reproducer under valgrind doesn't show any issues. Could you provide more details how you configured and build the binary? How exactly are you invoking it and what exactly is the complete output? -- You are receiving this mail because: You are on the CC list for the bug.