[lld] [LLD][AArch64] Implement relaxOnce to avoid dead GOT entries for relaxed ADRP+LDR (PR #224370)

Pranav Kant via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 24 19:20:32 PDT 2026


pranavk wrote:

One would find most savings from this patch when they are building in certain configurations. Eg: -fPIC (so every preemptible symbol is routed via GOT). For x86, this is not a problem because as long as binary is small, all of these single-instruction GOT references are going to be relaxed without leaving any dead GOT entries. For this reason, the GOT size for same binary on x86 is few hundred KiBs while it is in MiBs on AArch64. In AArch64, there are two reasons for increased GOT size. First is ADRP/LDR is not always together (~50% such instances in big binaries) making it impossible for linker to relax leading to increased GOT entries. Secondly, even after ADRP/LDR is relaxed, since we don't have `relaxOnce()` kind of function, we proactively add GOT entries and never remove them when they eventually get relaxed. This patch is targeting the second problem.

For AArch64 Chromium in default configuration which uses -fvisibility=hidden, there are around ~28% dead GOT entries. The number would likely be higher if we use -fvisibility=default.

For AArch64 clang (with all backends enabled) and -fPIC, there are around ~30% dead GOT entries.

While removing dead GOT entries and dynamic relocations helps with size as well, I think the main benefit is reduced number of dirty memory pages which as Peter mentioned can amount to non-trivial savings in memory constrained future. I haven't measured the startup time.

cc: @nico @zmodem if they want to chime in for Chromium.



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


More information about the llvm-commits mailing list