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.

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.

Your idea also sounds interesting. In the meantime i built a lld prototype, created a fixPath tool in rust and documented it in my blog:

* https://github.com/llvm/llvm-project/compare/release/18.x...qknight:llvm-project:libnix_PE-fixPath
* https://github.com/nixcloud/fixPath
* https://lastlog.de/blog/libnix_fixPath.html

I don't know ld very well, would someone here be interested in implementing the change i did for lld in ld? I'd pay for that, please give me a quote on how much that would cost to j...@lastlog.de directly.

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.


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.

Cheers
  Nick

Thanks & regards,
Joachim

Reply via email to