[lld] [lld][ELF] Merge equivalent symbols found during ICF (PR #139493)

Peter Smith via llvm-commits llvm-commits at lists.llvm.org
Wed May 21 03:01:30 PDT 2025


smithp35 wrote:

> 
> The proposed changes add considerable complexity, and I'm still uncertain about incorporating them into ICF.cpp. That said, thank you for creating the test cases! If I were designing an ABI, **I would simply disallow GOT code sequences that span multiple sections**.

I did try to see if there was any support internally for restricting this in the ABI. A summary of the outcome:
* This would be a retrospective change and there would need to be a very good case to make it.
* The known cases of this going wrong are limited to a combination of the outliner and ICF which haven't been strong enough to convince people on the GNU side that this would be worth making.
* There is an agreement that splitting apart ADRP and (ADD|LDR) is not a good idea as it inhibits optimisations by software and hardware (particularly on in order CPUs). GCC has moved in the direction of always keeping ADRP and (ADD|LDR) together. However this is a recommendation not a requirement.

So I don't think the ABI is going to mandate that the outliner be changed. However I think there's sufficient recommendation that there is justification to do it.

At the moment I expect GOT relocations to local symbols to be restricted to non-default code-models or extensions like memory tagging/PAuthABI.

Is there a cheaper way of detecting when this case has occurred? One alternative might be to detect and error out with a message to turn off icf, or the outliner if the binary is affected? I can't immediately think of one though.



https://github.com/llvm/llvm-project/pull/139493


More information about the llvm-commits mailing list