Fix seg-fault in linker when applying relocs to a corrupt binary.
authorNick Clifton <nickc@redhat.com>
Fri, 2 Dec 2016 15:03:05 +0000 (15:03 +0000)
committerNick Clifton <nickc@redhat.com>
Fri, 2 Dec 2016 15:03:05 +0000 (15:03 +0000)
PR ld/20911
* ldctor.c (ldctor_build_sets): Produce alternative error message
if the reloc was being applied to a special section.

ld/ChangeLog
ld/ldctor.c

index e9734ac95b922413a51903e3e07a9073a24c0f5b..1d1c91ae72f5121c1197f1ac361015ddba3cb3cb 100644 (file)
@@ -1,5 +1,9 @@
 2016-12-02  Nick Clifton  <nickc@redhat.com>
 
+       PR ld/20911
+       * ldctor.c (ldctor_build_sets): Produce alternative error message
+       if the reloc was being applied to a special section.
+
        PR ld/20912
        * emultempl/elf32.em (_place_orphan): Test for ELF format of the
        orphan before looking for the SHF_EXCLUDE flag.
index 2075ad34f2f998d192b93132040d79bc9e4b9278..505702aa53cd4ebbc9c892bf87c20342dff5c94e 100644 (file)
@@ -290,10 +290,17 @@ ldctor_build_sets (void)
                                           p->reloc);
          if (howto == NULL)
            {
-             einfo (_("%P%X: %s does not support reloc %s for set %s\n"),
-                    bfd_get_target (p->elements->section->owner),
-                    bfd_get_reloc_code_name (p->reloc),
-                    p->h->root.string);
+             /* See PR 20911 for a reproducer.  */
+             if (p->elements->section->owner == NULL)
+               einfo (_("%P%X: Special section %s does not support reloc %s for set %s\n"),
+                      bfd_get_section_name (link_info.output_bfd, p->elements->section),
+                      bfd_get_reloc_code_name (p->reloc),
+                      p->h->root.string);
+             else
+               einfo (_("%P%X: %s does not support reloc %s for set %s\n"),
+                      bfd_get_target (p->elements->section->owner),
+                      bfd_get_reloc_code_name (p->reloc),
+                      p->h->root.string);
              continue;
            }
        }
This page took 0.026711 seconds and 4 git commands to generate.