segfault in evaluate_complex_relocation_symbols
Alan Modra
amodra@bigpond.net.au
Thu Mar 29 09:23:00 GMT 2007
Fixes a segfault due to "unsigned long" not being large enough to
store r_info on a 32-bit host. These functions have code like
unsigned long r_symndx;
r_symndx = ELF32_R_SYM (rel->r_info);
bed = get_elf_backend_data (input_bfd);
if (bed->s->arch_size == 64)
r_symndx >>= 24;
ELF32_R_SYM just shifts right by 8, so if r_info is a 64-bit value you
lose the top 24 bits of the symbol index. An alternate fix would be
to use
unsigned long r_symndx;
bed = get_elf_backend_data (input_bfd);
if (bed->s->arch_size == 64)
r_symndx = rel->r_info >> 32;
else
r_symndx = rel->r_info >> 8;
PR ld/4267
* elflink.c (evaluate_complex_relocation_symbols): Use bfd_vma
for rel->r_info values.
(bfd_elf_perform_complex_relocation): Likewise.
Index: bfd/elflink.c
===================================================================
RCS file: /cvs/src/src/bfd/elflink.c,v
retrieving revision 1.253
diff -u -p -r1.253 elflink.c
--- bfd/elflink.c 7 Mar 2007 08:54:34 -0000 1.253
+++ bfd/elflink.c 29 Mar 2007 02:25:23 -0000
@@ -6758,7 +6758,7 @@ evaluate_complex_relocation_symbols (bfd
{
Elf_Internal_Rela * rel;
char * sym_name;
- unsigned long index;
+ bfd_vma index;
Elf_Internal_Sym * sym;
bfd_vma result;
bfd_vma section_offset;
@@ -6949,7 +6949,7 @@ bfd_elf_perform_complex_relocation
Elf_Internal_Shdr * symtab_hdr;
asection * sec;
bfd_vma relocation = 0, shift, x;
- unsigned long r_symndx;
+ bfd_vma r_symndx;
bfd_vma mask;
unsigned long start, oplen, len, wordsz,
chunksz, lsb0_p, signed_p, trunc_p;
--
Alan Modra
IBM OzLabs - Linux Technology Centre
More information about the Binutils
mailing list