[lld] r282149 - Fix VA computation for tbss.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 22 05:35:45 PDT 2016
Author: rafael
Date: Thu Sep 22 07:35:44 2016
New Revision: 282149
URL: http://llvm.org/viewvc/llvm-project?rev=282149&view=rev
Log:
Fix VA computation for tbss.
Modified:
lld/trunk/ELF/LinkerScript.cpp
lld/trunk/test/ELF/linkerscript/multiple-tbss.s
Modified: lld/trunk/ELF/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=282149&r1=282148&r2=282149&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Thu Sep 22 07:35:44 2016
@@ -357,11 +357,14 @@ static void assignSectionSymbol(SymbolAs
Body->Value = Cmd->Expression(Sec->getVA() + Off);
}
+template <class ELFT> static bool isTbss(OutputSectionBase<ELFT> *Sec) {
+ return (Sec->getFlags() & SHF_TLS) && Sec->getType() == SHT_NOBITS;
+}
+
template <class ELFT> void LinkerScript<ELFT>::output(InputSection<ELFT> *S) {
if (!AlreadyOutputIS.insert(S).second)
return;
- bool IsTbss =
- (CurOutSec->getFlags() & SHF_TLS) && CurOutSec->getType() == SHT_NOBITS;
+ bool IsTbss = isTbss(CurOutSec);
uintX_t Pos = IsTbss ? Dot + ThreadBssOffset : Dot;
Pos = alignTo(Pos, S->Alignment);
@@ -398,7 +401,7 @@ void LinkerScript<ELFT>::switchTo(Output
CurOutSec = Sec;
Dot = alignTo(Dot, CurOutSec->getAlignment());
- CurOutSec->setVA(Dot);
+ CurOutSec->setVA(isTbss(CurOutSec) ? Dot + ThreadBssOffset : Dot);
}
template <class ELFT> void LinkerScript<ELFT>::process(BaseCommand &Base) {
Modified: lld/trunk/test/ELF/linkerscript/multiple-tbss.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/multiple-tbss.s?rev=282149&r1=282148&r2=282149&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/multiple-tbss.s (original)
+++ lld/trunk/test/ELF/linkerscript/multiple-tbss.s Thu Sep 22 07:35:44 2016
@@ -2,7 +2,35 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
# RUN: echo "SECTIONS { }" > %t.script
# RUN: ld.lld -T %t.script %t.o -o %t
-# RUN: llvm-readobj -l %t | FileCheck %s
+# RUN: llvm-readobj -l -s %t | FileCheck %s
+
+# CHECK: Name: .tbss
+# CHECK-NEXT: Type: SHT_NOBITS
+# CHECK-NEXT: Flags [
+# CHECK-NEXT: SHF_ALLOC
+# CHECK-NEXT: SHF_TLS
+# CHECK-NEXT: SHF_WRITE
+# CHECK-NEXT: ]
+# CHECK-NEXT: Address:
+# CHECK-NEXT: Offset:
+# CHECK-NEXT: Size: 8
+# CHECK-NEXT: Link:
+# CHECK-NEXT: Info:
+# CHECK-NEXT: AddressAlignment:
+# CHECK-NEXT: EntrySize:
+# CHECK-NEXT: }
+# CHECK-NEXT: Section {
+# CHECK-NEXT: Index:
+# CHECK-NEXT: Name: foo
+# CHECK-NEXT: Type: SHT_NOBITS
+# CHECK-NEXT: Flags [
+# CHECK-NEXT: SHF_ALLOC
+# CHECK-NEXT: SHF_TLS
+# CHECK-NEXT: SHF_WRITE
+# CHECK-NEXT: ]
+# CHECK-NEXT: Address:
+# CHECK-NEXT: Offset:
+# CHECK-NEXT: Size: 1
# CHECK: Type: PT_TLS
# CHECK-NEXT: Offset:
More information about the llvm-commits
mailing list