The example reported in https://llvm.org/bugs/show_bug.cgi?id=30793 shows a case where gc reclaims a SHF_TLS section, but it doesn't recliam the section containing the debug info for it. This is, anyway, expected, as we do not reclaim non-alloc sections during the garbage collection phase (and this is not going to change anytime soon, at least this is what I gathered last I talked with Rafael about it).
So, we end up with a pending reference, thinking that the input was invalid (which is not true, as it's GC that removed the SH_TLS section, and therefore didn't create the PT_TLS *segment* for it). In cases like this, just assign a VA of zero at relocaiton time instead of error'ing out (this is what gold does as well, FWIW).
Details
Diff Detail
Event Timeline
ELF/InputSection.cpp | ||
---|---|---|
410–414 | This can be simplified to: uint64_t SymVA = 0; if (!Sym.isTls() || Out<ELFT>::TlsPhdr) SymVA = SignExtend64<sizeof(uintX_t) * 8>(getSymVA<ELFT>(Type, Addend, AddrLoc, Sym, R_ABS)); | |
test/ELF/gc-debuginfo-tls.s | ||
19–28 | This is a pretty obfuscated way to get a TLS symbol to a gced section. I think this can be simplified to something like: .section .tbss,"awT",@nobits patatino: .long 0 .section .noalloc,"" .quad patatino |
test/ELF/gc-debuginfo-tls.s | ||
---|---|---|
19–28 | This is reduced from the original testcase. But sure, I can add another test case if you want. |
test/ELF/gc-debuginfo-tls.s | ||
---|---|---|
19–28 | Sure, just add a comment to the .cfi* one saying that it was reduced from a testcase and that the debug info directives are generating the reference. |
This can be simplified to: