[PATCH] libdw, readelf: Handle GCC LTO .gnu.debuglto_ prefix.
Mark Wielaard
mark@klomp.org
Fri Apr 17 09:35:37 GMT 2020
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 <mark@klomp.org>
---
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 <mark@klomp.org>
+
+ * dwarf_begin_elf.c (check_section): Handle .gnu.debuglto_ prefix.
+
2019-10-28 Aaron Merey <amerey@redhat.com>
* 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 <mark@klomp.org>
+
+ * eblopenbackend.c (default_debugscn_p): Handle .gnu.debuglto_
+ prefix.
+
2020-02-08 Mark Wielaard <mark@klomp.org>
* 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 <mark@klomp.org>
+
+ * readelf.c (print_debug): Check .gnu.debuglto_ prefix.
+
2020-02-08 Mark Wielaard <mark@klomp.org>
* 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
More information about the Elfutils-devel
mailing list