[PATCH v3] bfd: fill in PE load config directory entry.

LIU Hao lh_mouse@126.com
Fri Mar 21 07:43:01 GMT 2025


在 2025-3-21 15:04, Jan Beulich 写道:
>> That's odd.  This matches what LLD does (though they do indeed do some
>> sanity checking):
>> https://github.com/llvm/llvm-project/blob/49f06075a6d298bd13564c9bffcf51281bed4962/lld/COFF/SymbolTable.cpp#L576
> 
> As one more data point, a quote from MS doc: "For Windows XP, the size must
> be specified as 64 for x86 images." It looks odd to me though that the exact
> same size is stated for both the 32- and 64-bit struct.
> 
> Since hopefully hardly anyone still cares about XP, doing what you do (and
> what llvm does) is likely fine, but imo wants to come with a code comment
> then.

If we would like to follow the specification [1], we can check the subsystem version. It specifies the 
Windows kernel version when the subsystem is `console` or windows`, which is

    * `5.1` for Windows XP x86-32;
    * `5.2` for Windows XP x86-64 and Windows Server 2003;
    * `6.0` for Windows Vista and Windows Server 2008 (default for x86);
    * `6.1` for Windows 7 and Windows Server 2008 R2.
    * `6.2` for Windows 8 and Windows Server 2012 (default for ARM).

So hard-coding the value to 64 when subsystem equals 5.1 makes some sense. LLVM seems to have a default 
value of 6.0, and in a sense they don't truly support XP.


[1] https://learn.microsoft.com/en-us/windows/win32/debug/pe-format#load-configuration-directory




-- 
Best regards,
LIU Hao
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature.asc
Type: application/pgp-signature
Size: 840 bytes
Desc: OpenPGP digital signature
URL: <https://sourceware.org/pipermail/binutils/attachments/20250321/6c75062d/attachment.sig>


More information about the Binutils mailing list