aboutsummaryrefslogtreecommitdiff
path: root/bfd/elflink.c
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2005-04-27 10:09:43 +0000
committerNick Clifton <nickc@redhat.com>2005-04-27 10:09:43 +0000
commit8c19749adc5f155f7a51f1799cd3494851c75909 (patch)
tree530bb469312d7c6df1444ea8ed0ced110dd0aa89 /bfd/elflink.c
parentf3429a74c5fde5da2bc2f56544c3149d823a1930 (diff)
downloadgdb-8c19749adc5f155f7a51f1799cd3494851c75909.zip
gdb-8c19749adc5f155f7a51f1799cd3494851c75909.tar.gz
gdb-8c19749adc5f155f7a51f1799cd3494851c75909.tar.bz2
(elf_link_input_bfd): Handle the case where a badly formatted input file results
in a reloc which has no associated global symbol
Diffstat (limited to 'bfd/elflink.c')
-rw-r--r--bfd/elflink.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/bfd/elflink.c b/bfd/elflink.c
index cd9131e..bf21780 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -7019,6 +7019,23 @@ elf_link_input_bfd (struct elf_final_link_info *finfo, bfd *input_bfd)
&& finfo->sections[r_symndx] == NULL))
{
h = sym_hashes[r_symndx - extsymoff];
+
+ /* Badly formatted input files can contain relocs that
+ reference non-existant symbols. Check here so that
+ we do not seg fault. */
+ if (h == NULL)
+ {
+ char buffer [32];
+
+ sprintf_vma (buffer, rel->r_info);
+ (*_bfd_error_handler)
+ (_("error: %B contains a reloc (0x%s) for section %A "
+ "that references a non-existent global symbol"),
+ input_bfd, o, buffer);
+ bfd_set_error (bfd_error_bad_value);
+ return FALSE;
+ }
+
while (h->root.type == bfd_link_hash_indirect
|| h->root.type == bfd_link_hash_warning)
h = (struct elf_link_hash_entry *) h->root.u.i.link;