public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* segfault in evaluate_complex_relocation_symbols
@ 2007-03-29  9:23 Alan Modra
  0 siblings, 0 replies; only message in thread
From: Alan Modra @ 2007-03-29  9:23 UTC (permalink / raw)
  To: binutils

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-03-29  2:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-29  9:23 segfault in evaluate_complex_relocation_symbols Alan Modra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).