[PATCH] bfd: fill in PE load config directory entry.
Jeremy Drake
sourceware-bugzilla@jdrake.com
Mon Mar 10 05:51:50 GMT 2025
On Mon, 10 Mar 2025, LIU Hao wrote:
> 在 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
Hmm, I noticed when I sent the patch that the address included
h1->root.u.def.value but I didn't include that when figuring out where to
read the size from. Could you try
if (bfd_get_section_contents (abfd, h1->root.u.def.section->output_section,
sz, hl->root.u.def.value + h1->root.u.def.section->output_offset, 4))
? Or maybe someone with knowledge of these APIs can shed some light on
what should be passed here.
More information about the Binutils
mailing list