diff options
author | Nick Clifton <nickc@redhat.com> | 2009-03-13 11:34:43 +0000 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2009-03-13 11:34:43 +0000 |
commit | ce98a316e9018523f263417f3948fed63a1ba1db (patch) | |
tree | 328e6f758f98e96ba4d3df6b1434c3d082ca98f2 /bfd/elf32-arm.c | |
parent | f7c60c5e2b07932c2b73b687083b254cbe0dd5de (diff) | |
download | gdb-ce98a316e9018523f263417f3948fed63a1ba1db.zip gdb-ce98a316e9018523f263417f3948fed63a1ba1db.tar.gz gdb-ce98a316e9018523f263417f3948fed63a1ba1db.tar.bz2 |
PR 9934
* elf-bfd.h (NUM_SHDR_ENTRIES): Cope with an empty section.
* elflink.c (elf_link_read_relocs_from_section): Use
NUM_SHDR_ENTRIES. Gracefully handle the case where there are
relocs but no symbol table.
* elf32-arm.c (elf32_arm_check_relocs): Likewise.
Diffstat (limited to 'bfd/elf32-arm.c')
-rw-r--r-- | bfd/elf32-arm.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c index f534290..226434a 100644 --- a/bfd/elf32-arm.c +++ b/bfd/elf32-arm.c @@ -9597,6 +9597,7 @@ elf32_arm_check_relocs (bfd *abfd, struct bfd_link_info *info, bfd_vma *local_got_offsets; struct elf32_arm_link_hash_table *htab; bfd_boolean needs_plt; + unsigned long nsyms; if (info->relocatable) return TRUE; @@ -9620,7 +9621,8 @@ elf32_arm_check_relocs (bfd *abfd, struct bfd_link_info *info, symtab_hdr = & elf_symtab_hdr (abfd); sym_hashes = elf_sym_hashes (abfd); - + nsyms = NUM_SHDR_ENTRIES (symtab_hdr); + rel_end = relocs + sec->reloc_count; for (rel = relocs; rel < rel_end; rel++) { @@ -9633,14 +9635,18 @@ elf32_arm_check_relocs (bfd *abfd, struct bfd_link_info *info, r_type = ELF32_R_TYPE (rel->r_info); r_type = arm_real_reloc_type (htab, r_type); - if (r_symndx >= NUM_SHDR_ENTRIES (symtab_hdr)) + if (r_symndx >= nsyms + /* PR 9934: It is possible to have relocations that do not + refer to symbols, thus it is also possible to have an + object file containing relocations but no symbol table. */ + && (r_symndx > 0 || nsyms > 0)) { (*_bfd_error_handler) (_("%B: bad symbol index: %d"), abfd, - r_symndx); + r_symndx); return FALSE; } - if (r_symndx < symtab_hdr->sh_info) + if (nsyms == 0 || r_symndx < symtab_hdr->sh_info) h = NULL; else { |