PATCH: PE COFF relocation overflow bug
Alan Modra
amodra@bigpond.net.au
Sun Jul 7 05:22:00 GMT 2002
On Fri, Jul 05, 2002 at 04:23:25PM -0700, Mark Mitchell wrote:
> Index: cofflink.c
> ===================================================================
> RCS file: /cvs/src/src/bfd/cofflink.c,v
> retrieving revision 1.33
> diff -c -p -r1.33 cofflink.c
> *** cofflink.c 7 Jun 2002 15:04:47 -0000 1.33
> --- cofflink.c 5 Jul 2002 23:11:32 -0000
> *************** _bfd_coff_final_link (abfd, info)
> *** 757,762 ****
> --- 757,766 ----
> o->flags |= SEC_RELOC;
> o->rel_filepos = rel_filepos;
> rel_filepos += o->reloc_count * relsz;
> + /* In PE COFF, if there are at least 0xffff relocations an
> + extra relocation will be written out to encode the count. */
> + if (obj_pe (abfd) && o->reloc_count >= 0xffff)
> + rel_filepos += relsz;
> }
>
> if (bfd_coff_long_section_names (abfd)
Either this patch, or coffcode.h:coff_write_relocs is wrong, as the
latter adds the extra reloc for reloc_count > 0xffff. Also, it seems
to me that you should be allocating the extra space #ifdef COFF_WITH_PE
rather than when obj_pe.
--
Alan Modra
IBM OzLabs - Linux Technology Centre
More information about the Binutils
mailing list