I’m working on support for Clang, Mach-O, and GNU linker scripts using LLD. Note: I am not targetting ld64 because the project would like to continue to use conventions for gcc / elf targets.
My end-goal is mainly to support the native_posix_64 target on macOS for Zephyr, which is a topic I will be speaking about at ZDS in a few days. Most of Zephyr’s targets are ELF and use gcc or llvm toolchains, and we would like to continue to use llvm for as close as a drop-in-replacement-as-possible for our purposes.
I posted about it a while ago and have some related work on adding
-fhashed-section-names=outfile on clang / clang++. The compiler frontend changes are working quite well, although there is room for improvement. The related change is here, and an example of the result is here.
The hash is one-way for all practical purposes and follows this (I’m quite flexible if there is a better, reversible alternative)
- Truncate to N
For, LLD, my planned changes are:
- add a corresponding
-hashed-section-names=infileoption (to reverse the hash)
- ~fork the ELF implementation and brute-force it to support Mach-O, potentially recycling some of the existing Mach-O implementation
- ~fork the linker script parser / impl and brute-force it to support with Mach-O binaries
- update the relevant config bits to enable parsing GNU linker scripts for the new target
Likely a lot of the brute-forcing will take several iterations to become clear and concise, but eventually, I would like to ensure that the work can either be merged back into the original subproject(s).
Just wondering if any of the LLD developers have any suggestions before I dive in.
Hope you are well,