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

LIU Hao lh_mouse@126.com
Mon Mar 10 02:41:33 GMT 2025


在 2025-3-10 06:32, Jeremy Drake 写道:
> +      /* the size is stored as the first 4 bytes at _load_config_used */
> +      if (bfd_get_section_contents (abfd, h1->root.u.def.section->output_section,
> +			      sz, h1->root.u.def.section->output_offset, 4))
> +	pe_data (abfd)->pe_opthdr.DataDirectory[PE_LOAD_CONFIG_TABLE].Size =
> +	  bfd_get_32 (abfd, sz);

There seems to be an issue in this code. You can try compiling this library:

  
https://github.com/lhmouse/mcfgthread/blob/a8d07be576f4089e383cc725b5cd1e83f9e6ab0e/mcfgthread/xglobals.c#L355

The load config directory was added for Clang-CL. It's always there even GNU LD doesn't use it.


With this patch I got:

    UCRT64 ~/GitHub/mcfgthread/build_release
    $ objdump -pw libmcfgthread-minimal-2.dll | grep -F 'Load Configuration Directory'
    Entry a 0000000000005120 0045004b Load Configuration Directory


The size field doesn't look quite right. It should be 0x140:

    UCRT64 ~/GitHub/mcfgthread/build_clang-cl
    $ objdump -pw libmcfgthread-minimal-2.dll | grep -F 'Load Configuration Directory'
    Entry a 0000000000008108 00000140 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/20250310/819463aa/attachment.sig>


More information about the Binutils mailing list