RFA: Detect corrupt relocs in mips BFD
Nick Clifton
nickc@cygnus.com
Fri Jul 21 10:14:00 GMT 2000
Hi Ulf,
I recently ran across a case where the MIPS linker was generating a
seg fault because it was being asked to process an input file with a
corrupt reloc section. The patch below fixes this by detecting
relocs with an out of range symbol index and issuing an error
message before causing the linker to terminate cleanly.
Is it OK to apply this patch ?
Cheers
Nick
2000-07-21 Nick Clifton <nickc@cygnus.com>
* elf32-mips.c (_bfd_mips_elf_check_relocs): Detect out of
range symbol indices in relocs and issue an error message.
Index: elf32-mips.c
===================================================================
RCS file: /cvs/src//src/bfd/elf32-mips.c,v
retrieving revision 1.74
diff -p -r1.74 elf32-mips.c
*** elf32-mips.c 2000/07/20 03:21:59 1.74
--- elf32-mips.c 2000/07/21 17:10:47
*************** _bfd_mips_elf_check_relocs (abfd, info,
*** 7593,7598 ****
--- 7593,7605 ----
if (r_symndx < extsymoff)
h = NULL;
+ else if (r_symndx >= extsymoff + (symtab_hdr->sh_size / symtab_hdr->sh_entsize))
+ {
+ (*_bfd_error_handler)
+ (_("Malformed reloc detected for section %s"), name);
+ bfd_set_error (bfd_error_bad_value);
+ return false;
+ }
else
{
h = sym_hashes[r_symndx - extsymoff];
More information about the Binutils
mailing list