diff options
-rw-r--r-- | lld/ELF/OutputSections.cpp | 7 | ||||
-rw-r--r-- | lld/test/elf2/tls-dynamic.s | 4 |
2 files changed, 7 insertions, 4 deletions
diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp index c6b74fffc46..ce7a3fc2067 100644 --- a/lld/ELF/OutputSections.cpp +++ b/lld/ELF/OutputSections.cpp @@ -719,11 +719,16 @@ lld::elf2::getLocalRelTarget(const ObjectFile<ELFT> &File, if (!Sym) error("Unsupported relocation without symbol"); + InputSectionBase<ELFT> *Section = File.getSection(*Sym); + + if (Sym->getType() == STT_TLS) + return (Section->OutSec->getVA() + Section->getOffset(*Sym) + Addend) - + Out<ELF64LE>::TlsPhdr->p_vaddr; + // According to the ELF spec reference to a local symbol from outside // the group are not allowed. Unfortunately .eh_frame breaks that rule // and must be treated specially. For now we just replace the symbol with // 0. - InputSectionBase<ELFT> *Section = File.getSection(*Sym); if (Section == &InputSection<ELFT>::Discarded || !Section->isLive()) return Addend; diff --git a/lld/test/elf2/tls-dynamic.s b/lld/test/elf2/tls-dynamic.s index 4c93c9c2f13..36a6129f923 100644 --- a/lld/test/elf2/tls-dynamic.s +++ b/lld/test/elf2/tls-dynamic.s @@ -18,9 +18,7 @@ .align 4 a: .long 0 - - .global b - .hidden b + .section .tbss,"awT",@nobits .align 4 b: |