Hi All,
I have implemented a way to attach link-time information via linker-generated function/variable attributes to the combined IR to be utilized during an LTO recompile. I’d like to upstream this capability if it makes sense.
Some useful scenarios include:
-
Communicating placement information from a linker script associated with a given input section where a particular function or variable is defined. This information might be used to determine whether a constant in one input section can be merged with a constant from another input section during the LTO recompile.
-
Identifying the original ELF object file that a given input section came from so that the information can be attached to a given function or variable section during the LTO recompile, then fed back to the linker in the LTO generated object file to help the linker honor placement constraints on the input section that may be specified via the original ELF object file name in a linker script.
Does the LLVM lld already do something like this via linker-generated attributes or some other mechanism?
Thanks and Regards,
Todd Snider
Hello,
To the best of my knowledge upstream LLD doesn’t do anything like this at the moment. There was a talk some years ago at an LLVM dev meeting that did something like this in https://llvm.org/devmtg/2017-10/slides/LTOLinkerScriptsEdlerVonKoch.pdf however there wasn’t any upstream work that came of this.
LTO and the challenges of linker scripts did come up at the last LLVM Embedded Toolchains meeting LLVM Embedded Toolchains Working Group sync up - #10 by voltur01 I think that good linker script support will be necessary for LTO to see wide spread use in embedded systems, so I’m looking forward to seeing this happen. I’m more of a linker person than compiler, so I can offer to help with LLD reviews.
From memory LLD assigns input sections to output sections fairly late, certainly after LTO code-generation. Although I think it does scan the linker script early for some things, and it may be the case that only a small amount of section assignment needs to be done prior to LTO.
Hi Peter,
Our linker does input to output section assignment while it is registering input sections that are known to be needed in a link, right prior to configuring and running the LTO backend.
Thanks for the response, the pointers to prior discussion, and for volunteering help with LLD reviews. I will definitely keep you posted on my progress moving this forward.
Regards,
Todd Snider