]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
GC: Also check the local debug definition section
authorH.J. Lu <hjl.tools@gmail.com>
Wed, 14 Mar 2018 11:23:24 +0000 (04:23 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Wed, 14 Mar 2018 11:23:40 +0000 (04:23 -0700)
Extend

commit b7c871edcd83ccdc5fcd8148a7f433efd6b52255
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Wed May 17 07:57:15 2017 -0700

    Mark debug sections referenced by kept debug sections

to handle the local debug definition section.

bfd/

PR ld/20882
* elflink.c (elf_gc_mark_debug_section): Also check the local
debug definition section.

ld/

PR ld/20882
* testsuite/ld-gc/pr20882.d: Also dump and check .debug_abbrev
section.
* testsuite/ld-gc/pr20882b.s: Add .debug_abbrev section.

bfd/ChangeLog
bfd/elflink.c
ld/ChangeLog
ld/testsuite/ld-gc/pr20882.d
ld/testsuite/ld-gc/pr20882b.s

index ddf0d041fcdbf903b8f32572ba621067d3fc5a6f..ad971fc20780024b8178c28d8069db3420e125f1 100644 (file)
@@ -1,3 +1,9 @@
+2018-03-14  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR ld/20882
+       * elflink.c (elf_gc_mark_debug_section): Also check the local
+       debug definition section.
+
 2018-03-13  Nick Clifton  <nickc@redhat.com>
 
        PR 22113
index 092edaea261bb4673c0fc836b693119809a6697e..6a3d516ba8a5002614c22e1bc111f9c54aea894b 100644 (file)
@@ -12802,20 +12802,31 @@ _bfd_elf_gc_mark_hook (asection *sec,
   return NULL;
 }
 
-/* Return the global debug definition section.  */
+/* Return the debug definition section.  */
 
 static asection *
 elf_gc_mark_debug_section (asection *sec ATTRIBUTE_UNUSED,
                           struct bfd_link_info *info ATTRIBUTE_UNUSED,
                           Elf_Internal_Rela *rel ATTRIBUTE_UNUSED,
                           struct elf_link_hash_entry *h,
-                          Elf_Internal_Sym *sym ATTRIBUTE_UNUSED)
+                          Elf_Internal_Sym *sym)
 {
-  if (h != NULL
-      && (h->root.type == bfd_link_hash_defined
-         || h->root.type == bfd_link_hash_defweak)
-      && (h->root.u.def.section->flags & SEC_DEBUGGING) != 0)
-    return h->root.u.def.section;
+  if (h != NULL)
+    {
+      /* Return the global debug definition section.  */
+      if ((h->root.type == bfd_link_hash_defined
+          || h->root.type == bfd_link_hash_defweak)
+         && (h->root.u.def.section->flags & SEC_DEBUGGING) != 0)
+       return h->root.u.def.section;
+    }
+  else
+    {
+      /* Return the local debug definition section.  */
+      asection *isec = bfd_section_from_elf_index (sec->owner,
+                                                  sym->st_shndx);
+      if ((isec->flags & SEC_DEBUGGING) != 0)
+       return isec;
+    }
 
   return NULL;
 }
index a750599c91cb2429e49bab7f15a5a66f78fac77a..e74f7222c607c3adf426cb6b9951020b1651675d 100644 (file)
@@ -1,3 +1,10 @@
+2018-03-14  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR ld/20882
+       * testsuite/ld-gc/pr20882.d: Also dump and check .debug_abbrev
+       section.
+       * testsuite/ld-gc/pr20882b.s: Add .debug_abbrev section.
+
 2018-03-14  H.J. Lu  <hongjiu.lu@intel.com>
 
        * testsuite/ld-gc/gc.exp: Fix a typo: $LFLAGS -> $LDFLAGS.
index dd388c51c960aed06f5b1db6c41087dce09b2896..1d68d05f38b9113d34ddbf54436be84a2e772f86 100644 (file)
@@ -3,7 +3,10 @@
 #source: pr20882b.s
 #source: pr20882c.s
 #ld: --gc-sections -e main
-#readelf: -x .debug_info
+#readelf: -x .debug_info -x .debug_abbrev
 
-#...
-  0x0+ (0a000000 00000000 |00000000 0000000a |06000000 |00000006 |0400|0004)28 .*
+Hex dump of section '\.debug_info':
+  0x0+ .*
+
+Hex dump of section '\.debug_abbrev':
+  0x0+ 61626364 +abcd
index ea0cf2e4adad95812587ea0afae05f5ef991577f..baabf557793cda862a590fdc6a836e9c5d981537 100644 (file)
@@ -2,4 +2,11 @@
        .hidden t.c.4903c230
        .globl t.c.4903c230
 t.c.4903c230:
-       .byte 0x28
+       .dc.a  .Ldebug_abbrev0
+
+       .section .debug_abbrev,"",%progbits
+.Ldebug_abbrev0:
+       .byte 0x61
+       .byte 0x62
+       .byte 0x63
+       .byte 0x64