This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: PATCH: PE COFF relocation overflow bug
- From: Alan Modra <amodra at bigpond dot net dot au>
- To: Mark Mitchell <mark at codesourcery dot com>
- Cc: binutils at sources dot redhat dot com
- Date: Sun, 7 Jul 2002 21:20:46 +0930
- Subject: Re: PATCH: PE COFF relocation overflow bug
- References: <33830000.1025911405@gandalf.codesourcery.com>
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