[lld] [ELF] Add target-specific relocation scanning for x86 (PR #178846)
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 30 09:21:18 PST 2026
MaskRay wrote:
> Rather than having to duplicate the implementation of these for each target (which, aside from being a bunch of extra code to write, will eventually lead to divergent implementations as features or bug fixes get added to one but not another), would it not be better to keep the single implementation but template it so the compiler can do the specialisation for us?
In `X86_64::scanSectionImpl`, although the initial code has some duplication when extracting relocation members, the switch table elegantly merges `getRelExpr` with the concrete action - dispatching to functions like `rs.scanPCRel`, `rs.scanTlsGd`, and `rs.handleTlsDesc` to ensure code sharing. Placing this code in `RelocScan.h` would make emitting a jump table code generation challenging. The switch table also keeps target-specific special cases (like AArch64 pauth, which I'll migrate next) from polluting the generic code.
https://github.com/llvm/llvm-project/pull/178846
More information about the llvm-commits
mailing list