On 2024-06-05 15:15, Nick Clifton wrote:
Hi Joachim,
I'd like to extend the ld generated PE section with a custom section
called .store in analogy to .idata and I would love a little guidance
where to make this change.
I would recommend that rather than doing this in the linker, you
perform it as an additional step after the linking has completed,
using objcopy's --add-section command line option. This means
that the solution will work with the current tools, and it will
give you a chance to post-process the linked binary to extract
any information that you need to store into the new section.
I tried this on Windows but it only works when using objcopy on .o files
and would corrupt the program when applied to .exe (PE) which is in
contrast to linux, where ld was able to do this modification also on the
executable (ELF).
In the meantime I implemented this feature using LLD:
the LLD patch I created:
https://github.com/qknight/llvm-project/tree/libnix_PE-fixPath
the documentation (WIP)
https://github.com/nixcloud/fixPath/
If you do want to use the linker, then the first place to look
is the linker script ld/scripttemp/pep.sc. This is where you
should place a definition of the new section.
this is good to know, thanks! i probably will want to patch ld like i
did for lld.
The new field must be generated after the idata has been generated.
Which as I assume you have discovered is done inside ld/pe-dll.c.
that file is huge, i stumbled around without knowing much.
In addition I need to know where the dllname name, foo.dll is
generated as I need to change this as well to reserve like 300 more
chars for later changes of said dllname.
I am not sure what you mean here, but probably the code you are
looking for is in ld/emultempl/pe.em and/or ld/emultempl/pep.em.
Either there or bfd/peicode.h.
maybe the two links I've added help you understand what I was after.
basically i need to add a new section .fixPath (i call it now) and in
addition extend the dllName fields with ~300 chars so later renames have
space without requiring relocations.
Cheers
Nick
thanks for your help!
--
https://lastlog.de/blog