aboutsummaryrefslogtreecommitdiff
path: root/ld/ldctor.c
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2016-12-02 15:03:05 +0000
committerNick Clifton <nickc@redhat.com>2016-12-02 15:03:05 +0000
commitfe6fae079099c0eeb3186086d6b150800c0e8770 (patch)
treeb3c1d03b4687b6c57956b3bbe5827da8f035f7cb /ld/ldctor.c
parent233c8c27eb81b0a3ab5182dcb59c7306ba9bd3f3 (diff)
downloadgdb-fe6fae079099c0eeb3186086d6b150800c0e8770.zip
gdb-fe6fae079099c0eeb3186086d6b150800c0e8770.tar.gz
gdb-fe6fae079099c0eeb3186086d6b150800c0e8770.tar.bz2
Fix seg-fault in linker when applying relocs to a corrupt binary.
PR ld/20911 * ldctor.c (ldctor_build_sets): Produce alternative error message if the reloc was being applied to a special section.
Diffstat (limited to 'ld/ldctor.c')
-rw-r--r--ld/ldctor.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/ld/ldctor.c b/ld/ldctor.c
index 2075ad3..505702a 100644
--- a/ld/ldctor.c
+++ b/ld/ldctor.c
@@ -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;
}
}