This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Fix elflink crash with both rel and rela sections


I'm working on the C6x port, where we want to test for compatibility
with TI's compiler.  That compiler generates object files which have
both rel.text and rela.text sections, and the linker crashes when
reading one these files.

In _bfd_elf_link_read_relocs, we have

  if (elf_section_data (o)->rel_hdr2
      && (!elf_link_read_relocs_from_section
	  (abfd, o,
	   elf_section_data (o)->rel_hdr2,
	   ((bfd_byte *) external_relocs) + rel_hdr->sh_size,
	   internal_relocs + (NUM_SHDR_ENTRIES (rel_hdr)
			      * bed->s->int_rels_per_ext_rel))))
    goto error_return;

IIUC, we're reading the contents of both the REL and RELA section into a
single buffer.  However, when allocating the buffer, we count only the
size of one the sections in max_external_reloc_size.

The patch below fixes the crash, and in gdb it looks like it's
allocating the exact amount needed now.  Ok?


Bernd

Attachment: elflink.diff
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]