]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
libdw, readelf: Handle GCC LTO .gnu.debuglto_ prefix.
authorMark Wielaard <mark@klomp.org>
Fri, 17 Apr 2020 09:31:40 +0000 (11:31 +0200)
committerMark Wielaard <mark@klomp.org>
Tue, 21 Apr 2020 22:02:20 +0000 (00:02 +0200)
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
libdw/dwarf_begin_elf.c
libebl/ChangeLog
libebl/eblopenbackend.c
src/ChangeLog
src/readelf.c

index 59f33f9e3136b816f59c76dbcd60d26da0ce8771..39730fbc7238b3b4fb268697308ca4d91d61fb07 100644 (file)
@@ -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.
index 853430882fb91ea2e2277c5ba1b0ad5ed882d505..474ed1389a525a65d262ddbf438b6ad6123f12a3 100644 (file)
@@ -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)
index b328731043c39c1c71197a80b23c68321baf4fc5..90cf97281bb959636af4d72fa91e76a091104aba 100644 (file)
@@ -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
index 210b47e887a47084da106523c4ee3fac955eae2a..4ebde45f24f845efd1ae237ba8cc9595b788be81 100644 (file)
@@ -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;
index dc345a04fc668a435b64ade9446d071a16a5a591..83d5860715159c146df83973d6b4a7fc34c867c4 100644 (file)
@@ -1,3 +1,7 @@
+2020-04-17  Mark Wielaard  <mark@klomp.org>
+
+       * readelf.c (print_debug): Check .gnu.debuglto_ prefix.
+
 2020-04-16  Mark Wielaard  <mark@klomp.org>
 
        * elflint.c (check_sections): Mask out SHF_EXCLUDE from processor
index cbb519d1890df9f71f271059bcf701f216debacd..685d0b17728685db79ab58f606179dac96499c03 100644 (file)
@@ -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)