This is the mail archive of the binutils@sourceware.org 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: binutils arm/PE issue causing failure on Windows Mobile 6.1+


2009/9/6 Danny Backx <danny.backx@scarlet.be>:
> On Sun, 2009-09-06 at 18:38 +0200, Kai Tietz wrote:
>> 2009/9/6 Danny Backx <danny.backx@scarlet.be>:
>> > I'm forwarding w.r.t. an issue with cegcc (creating WinCE executables
>> > for ARM).
>> >
>> > We've had several reports over the last year, which were eventually
>> > tracked down to issues with the PE format exes we create.
>>
>> I have a patch for fixing IAT size for PE-coff. The issue why I didn't
>> posted it was, that the IAT for pseudo-relocation version 1 is badly
>> corrupt, and it makes no sense to output size here. For version 2 of
>> it, a proper IAT is written, as IAT and ILT have to be equal in size
>> and each has to be written as one block, but for pseudo-relocation
>> version 1 the IAT can be found all over the executable.
>
> I'm afraid you're way ahead of me. Is version 1 vs version 2 something I
> could select as a build option when compiling an application ? Or does
> it depend on other factors ?
>
> It must not be as easy as that...
>
> Where can I find info on version 1 vs version 2 ?
>
> Thanks,
>
> ? ? ? ?Danny
> --
> Danny Backx ; danny.backx - at - scarlet.be ; http://danny.backx.info
>
>

Hello Danny,

as far as I know, there is just some technical documentation in
comments of ld's pe-dll.c about it. But I try to summarize where the
difference are between those two different pseudo-relocation
implementation - Dave if you think I missed here something, please
comment, too.

The pseudo-relocation version 1 (afterward just as v1) uses for each
auto-imported symbol an new import table (even for same symbol
multiple times), as it sets the IAT RVA address within code/data
section, where it occurs. Additionally there is the the
pseudo-relocation table - which is handled by startup code - which
adds necessary deltas to the the relocation. By this you can see that
by v1 the PE header is growing pretty much for and it needs that code
and read-only section have to have write privileges for startup-code.
Additionally there is no block of IATs, and the size of relocation has
to have IMAGEBASE_RELOC size.

For base relocation version 2 (afterward as v2) symbol gets just once
imported and the IATs are placed into one coherent block. By this for
each import table the IAT can be exported with proper size. The
pseudo-relocation table - which is handled by startup code - contains
the location and size of relocation - handles to change for
modification the write-privilege temporary and is able to do
relocations <= IMAGEBASE_RELOC. By v2 the pe-header gets smaller and
there is no need to change section write-privilege by linker anymore.
Also it allows to handle const struct, and smaller relative
relocations without issue.

v1 is at the moment AFAIK default for cygwin and windows 32-bit
targets. For 64-bit window target v2 is already default, as v1 isn't
usable for it at all.

I hope I could give you some help

Cheers,
Kai
-- 
|  (\_/) This is Bunny. Copy and paste
| (='.'=) Bunny into your signature to help
| (")_(") him gain world domination


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