PATCH: Check bad symbol index in ia64 reloc

Alan Modra amodra@bigpond.net.au
Thu Sep 25 00:28:00 GMT 2003


On Wed, Sep 24, 2003 at 11:33:48AM -0700, H. J. Lu wrote:
> 	* elflink.c (elf_link_read_relocs_from_section): Add an argument
> 	of a pointer to section. Check bad symbol index.
> 	(_bfd_elf_link_read_relocs): Modify calls to
> 	elf_link_read_relocs_from_section.

> +      r_symndx = (bfd_get_arch_size (abfd) == 32)
> +		  ? ELF32_R_SYM (irela->r_info)
> +		  : ELF64_R_SYM (irela->r_info);

This will generate warnings when only building for 32 bit hosts, and
it would be better without the bfd_get_arch_size call.

      r_symndx = ELF32_R_SYM (irela->r_info);
      if (bed->s->arch_size == 64)
	r_symndx >>= 24;

OK with the above.

Hmm, even better, test r_info directly against a maximum value
calculated outside of the loop.  If you go this way, you probably want
to simplify the error message by not reporting r_symndx and nsyms.

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre



More information about the Binutils mailing list