This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Note that .rela.debug* sections are debuginfo sections.


Without this fix, strip -g misbehaves when stripping object files
and other ELF objects containing debuginfo relocation sections,
preserving all debuginfo sections in the output file because the
.rela.debug* sections reference them.

Signed-off-by: Nick Alcock <nick.alcock@oracle.com>
---
The selection of sections to RELAFY here is pretty much arbitrary,
covering everything I've seen .rela.* created for and anything else that
seems likely to need it.

Testing is trivial: try to strip -g a Linux kernel module (or any other
object file containing debug info) and observe the .debug* and
.rela.debug* sections turning up in the stripped output rather than (if
specified) the -f file.  binutils behaves correctly in this area.

I haven't considered DWARF 1 sections not shared with DWARF 2+ at all
because I have no way to generate such sections for testing.

 libebl/ChangeLog        |  5 +++++
 libebl/eblopenbackend.c | 36 +++++++++++++++++++-----------------
 2 files changed, 24 insertions(+), 17 deletions(-)

diff --git a/libebl/ChangeLog b/libebl/ChangeLog
index af819a2..c6204c6 100644
--- a/libebl/ChangeLog
+++ b/libebl/ChangeLog
@@ -1,3 +1,8 @@
+2012-09-18  Nick Alcock  <nick.alcock@oracle.com>
+
+	* eblopenbackend.c (default_debugscn_p): Add .rela.* versions of
+	many DWARF 2+ debuginfo sections.
+
 2012-08-22  Jeff Kenton  <jkenton@tilera.com>
 
 	* eblopenbackend.c (machines): Add tilegx.
diff --git a/libebl/eblopenbackend.c b/libebl/eblopenbackend.c
index 89e5da5..d10b0d0 100644
--- a/libebl/eblopenbackend.c
+++ b/libebl/eblopenbackend.c
@@ -619,6 +619,7 @@ default_object_note (const char *name __attribute__ ((unused)),
 static bool
 default_debugscn_p (const char *name)
 {
+#define RELAFY(x) x, ".rela" x
   /* We know by default only about the DWARF debug sections which have
      fixed names.  */
   static const char *dwarf_scn_names[] =
@@ -630,31 +631,32 @@ default_debugscn_p (const char *name)
       ".debug_srcinfo",
       ".debug_sfnames",
       /* DWARF 1.1 and DWARF 2 */
-      ".debug_aranges",
-      ".debug_pubnames",
+      RELAFY(".debug_aranges"),
+      RELAFY(".debug_pubnames"),
       /* DWARF 2 */
-      ".debug_info",
-      ".debug_abbrev",
-      ".debug_line",
-      ".debug_frame",
-      ".debug_str",
-      ".debug_loc",
-      ".debug_macinfo",
+      RELAFY(".debug_info"),
+      RELAFY(".debug_abbrev"),
+      RELAFY(".debug_line"),
+      RELAFY(".debug_frame"),
+      RELAFY(".debug_str"),
+      RELAFY(".debug_loc"),
+      RELAFY(".debug_macinfo"),
       /* DWARF 3 */
-      ".debug_ranges",
-      ".debug_pubtypes",
+      RELAFY(".debug_ranges"),
+      RELAFY(".debug_pubtypes"),
       /* DWARF 4 */
-      ".debug_types",
+      RELAFY(".debug_types"),
       /* GDB DWARF 4 extension */
       ".gdb_index",
       /* GNU/DWARF 5 extension/proposal */
-      ".debug_macro",
+      RELAFY(".debug_macro"),
       /* SGI/MIPS DWARF 2 extensions */
-      ".debug_weaknames",
-      ".debug_funcnames",
-      ".debug_typenames",
-      ".debug_varnames"
+      RELAFY(".debug_weaknames"),
+      RELAFY(".debug_funcnames"),
+      RELAFY(".debug_typenames"),
+      RELAFY(".debug_varnames")
     };
+#undef RELAFY
   const size_t ndwarf_scn_names = (sizeof (dwarf_scn_names)
 				   / sizeof (dwarf_scn_names[0]));
   for (size_t cnt = 0; cnt < ndwarf_scn_names; ++cnt)
-- 
1.7.12.156.gd7c4257


-- 
NULL && (void)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]