If we pass --gc-sections to lld and .tbss is not referenced, it gets reclaimed and we don't create a TLS program header.
R_TLS tries to access the program header -> lld crashes. Mimic what bfd/gold do in this case and resolve a weak undefined TLS symbol to the base of the TLS block, i.e. give it a value of zero.
Details
Details
Diff Detail
Diff Detail
Event Timeline
ELF/InputSection.cpp | ||
---|---|---|
249 | We should never call getSymVA() on a lazy symbol, so isLazy() is always false. But if so, your code cannot change the behavior of this function. So something's not correct. |
Comment Actions
I think we treat weak undefined specially. http://llvm.org/viewvc/llvm-project?view=revision&revision=261591
isLazy() returns true. At least it did when I stepped through inside a debugger.
Comment Actions
I don't think the invariant you point out is respected (we should never call getSymVA() on a Lazy symbol).
I was lazy, and to convince myself I put the following assertion in the code:
diff --git a/ELF/InputSection.cpp b/ELF/InputSection.cpp index 3cc6ce5..b44d2d9 100644 --- a/ELF/InputSection.cpp +++ b/ELF/InputSection.cpp @@ -185,6 +185,7 @@ template <class ELFT> static typename ELFT::uint getSymVA(uint32_t Type, typename ELFT::uint A, typename ELFT::uint P, const SymbolBody &Body, RelExpr Expr) { + assert (!Body.isLazy() && "patatino"); switch (Expr) { case R_HINT: llvm_unreachable("cannot relocate hint relocs");
and saw three tests failing:
******************** Testing Time: 17.63s ******************** Failing Tests (3): lld :: ELF/archive.s lld :: ELF/lto/undef-weak.ll lld :: ELF/tls-in-archive.s
Still, maybe this is not the best place to check.
We should never call getSymVA() on a lazy symbol, so isLazy() is always false. But if so, your code cannot change the behavior of this function. So something's not correct.