This is the mail archive of the 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]

Re: PATCH: PE COFF relocation overflow bug

--On Monday, July 08, 2002 10:50:18 AM +0930 Alan Modra <> wrote:

On Sun, Jul 07, 2002 at 07:43:43PM -0000, Mark Mitchell wrote:
--On Sunday, July 07, 2002 9:20 PM +0930 Alan Modra
<>  wrote:
> 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.
Please.  They need to be consistent.
OK.  But, I don't want to get entangled in doing a major cleanup -- I
don't have time.

> 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.
Hmm, it wouldn't be the first occurrence of #ifdef COFF_WITH_PE in
There's one other.  That use is ineffectual.  Nothing sets COFF_WITH_PE
when compiling cofflink.c, ever.  COFF_WITH_PE is only set in files
like pe-i386.c, and they don't include cofflink.c.

(I actually tried using COFF_WITH_PE first; it was when I figured out
it didn't work that I discovered obj_pe.)

pe and coff objects, when configuring for a pe target.  That's why I
suggested #ifdef COFF_WITH_PE, for consistency.  Of course, this might
just be consistently wrong...
It's worse than that; it won't even fix the bug I found.

Better might be to use obj_pe in all places that twiddle reloc_count.
That way you could configure for a pe target and have some hope of
building a coff object with 0xffff relocs.
Well, that might be cleaner.  But coffcode.h *does* get compiled
multiple times; it's included from every coff target.  So, using
COFF_WITH_PE does work in coffcode.h -- just not in cofflink.c.

I'd prefer to leave y'all to disentangle this mess.  May I check in the
fix, plus the twiddling from ">" to ">=" in coffcode.h?

Mark Mitchell      
CodeSourcery, LLC  

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