[lld] [lld][ELF] Reject TLS relocations against non-STT_TLS symbols (PR #228418)

Peter Smith via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 2 06:54:11 PDT 2026


================

----------------
smithp35 wrote:

I think all relocations pass through this function before being dispatched to the various target specific relocation processing.

Would it be possible to check here, like the check for undefined symbols below?

I expect something like (pseudo-code)
```
if (isTLSExpr(expr) && !sym->isTls())
  error TLS relocation to non-TLS symbol
else if (!isTLSExpr(expr) && sym->isTLS())
  error non-TLS relocation to TLS symbol
```
I guess it would be possible to query the target for the specific relocation code, if the expression isn't good enough, although I expect it should be.

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


More information about the llvm-commits mailing list