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: Mark Mitchell <mark at codesourcery dot com>
- To: Alan Modra <amodra at bigpond dot net dot au>
- Cc: "binutils at sources dot redhat dot com" <binutils at sources dot redhat dot com>
- Date: Sun, 07 Jul 2002 19:43:43 -0000
- Subject: Re: PATCH: PE COFF relocation overflow bug
--On Sunday, July 07, 2002 9:20 PM +0930 Alan Modra <amodra@bigpond.net.au>
wrote:
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
The coffcode.h one is wrong. I checked this with the Microsoft compiler.
(And, if you think about it, the only consistent choice is >=; the 0xffff
tells you that you need to look in the relocation table. ) I can make
that change too, if you want.
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.
That doesn't work; this file is not #include'd elsewhere -- it's only
compiled once. So, you need a runtime check; hence obj_pe.
Unless that doesn't do what I think it does...
--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com