Fix elflink crash with both rel and rela sections
Bernd Schmidt
bernds@codesourcery.com
Wed Sep 8 23:20:00 GMT 2010
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
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: elflink.diff
URL: <https://sourceware.org/pipermail/binutils/attachments/20100908/02442f5a/attachment.ksh>
More information about the Binutils
mailing list