[ELF] - Stop support of DF_STATIC_TLS flag.

This reverts changes introduced in r302414 "[ELF] - Set DF_STATIC_TLS flag for i386 target."

Because DF_STATIC_TLS does not look to be used by glibc or anything else.

llvm-svn: 302884
This commit is contained in:
George Rimar 2017-05-12 08:04:58 +00:00
parent 63c9c81152
commit b4081bb0ab
11 changed files with 80 additions and 149 deletions

View File

@ -73,7 +73,6 @@ struct VersionDefinition {
// Most fields are initialized by the driver.
struct Configuration {
InputFile *FirstElf = nullptr;
bool HasStaticTlsModel = false;
uint8_t OSABI = 0;
llvm::CachePruningPolicy ThinLTOCachePolicy;
llvm::StringMap<uint64_t> SectionStartMap;

View File

@ -1035,15 +1035,6 @@ template <class ELFT> void DynamicSection<ELFT>::addEntries() {
if (!Config->SoName.empty())
add({DT_SONAME, InX::DynStrTab->addString(Config->SoName)});
if (!Config->Shared && !Config->Relocatable)
add({DT_DEBUG, (uint64_t)0});
}
// Add remaining entries to complete .dynamic contents.
template <class ELFT> void DynamicSection<ELFT>::finalizeContents() {
if (this->Size)
return; // Already finalized.
// Set DT_FLAGS and DT_FLAGS_1.
uint32_t DtFlags = 0;
uint32_t DtFlags1 = 0;
@ -1061,14 +1052,21 @@ template <class ELFT> void DynamicSection<ELFT>::finalizeContents() {
DtFlags |= DF_ORIGIN;
DtFlags1 |= DF_1_ORIGIN;
}
if (Config->HasStaticTlsModel)
DtFlags |= DF_STATIC_TLS;
if (DtFlags)
add({DT_FLAGS, DtFlags});
if (DtFlags1)
add({DT_FLAGS_1, DtFlags1});
if (!Config->Shared && !Config->Relocatable)
add({DT_DEBUG, (uint64_t)0});
}
// Add remaining entries to complete .dynamic contents.
template <class ELFT> void DynamicSection<ELFT>::finalizeContents() {
if (this->Size)
return; // Already finalized.
this->Link = InX::DynStrTab->OutSec->SectionIndex;
if (In<ELFT>::RelaDyn->OutSec->Size > 0) {
bool IsRela = Config->IsRela;

View File

@ -351,15 +351,6 @@ X86TargetInfo::X86TargetInfo() {
RelExpr X86TargetInfo::getRelExpr(uint32_t Type, const SymbolBody &S,
const uint8_t *Loc) const {
// There are 4 different TLS variable models with varying degrees of
// flexibility and performance. LocalExec and InitialExec models are fast but
// less-flexible models. They cannot be used for dlopen(). If they are in use,
// we set DF_STATIC_TLS in the ELF header so that the runtime can reject such
// DSOs.
if (Type == R_386_TLS_LE || Type == R_386_TLS_LE_32 || Type == R_386_TLS_IE ||
Type == R_386_TLS_GOTIE)
Config->HasStaticTlsModel = true;
switch (Type) {
case R_386_8:
case R_386_16:

View File

@ -1,10 +0,0 @@
.section ".tdata", "awT", @progbits
.globl var
var:
.section .foo, "aw"
.global _start
_start:
movl $var@tpoff, %edx # R_386_TLS_LE_32
movl %gs:0, %ecx
subl %edx, %eax

View File

@ -1,9 +0,0 @@
.section ".tdata", "awT", @progbits
.globl var
var:
.section .foo, "aw"
.global _start
_start:
movl %gs:0, %eax
addl var@gotntpoff(%ebx),%eax # R_386_TLS_GOTIE

View File

@ -1,9 +0,0 @@
.section ".tdata", "awT", @progbits
.globl var
var:
.section .foo, "aw"
.global _start
_start:
movl %gs:0, %eax
addl var@indntpoff, %eax #R_386_TLS_IE

View File

@ -1,9 +0,0 @@
.section ".tdata", "awT", @progbits
.globl var
var:
.section .foo, "aw"
.global _start
_start:
movl %gs:0, %eax
leal var@ntpoff(%eax), %eax #R_386_TLS_LE

View File

@ -1,20 +0,0 @@
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=i686-pc-linux %S/Inputs/i386-static-tls-model1.s -o %t.o
# RUN: ld.lld %t.o -o %t1 -shared
# RUN: llvm-readobj -dynamic-table %t1 | FileCheck %s
# RUN: llvm-mc -filetype=obj -triple=i686-pc-linux %S/Inputs/i386-static-tls-model2.s -o %t.o
# RUN: ld.lld %t.o -o %t2 -shared
# RUN: llvm-readobj -dynamic-table %t2 | FileCheck %s
# RUN: llvm-mc -filetype=obj -triple=i686-pc-linux %S/Inputs/i386-static-tls-model3.s -o %t.o
# RUN: ld.lld %t.o -o %t3 -shared
# RUN: llvm-readobj -dynamic-table %t3 | FileCheck %s
# RUN: llvm-mc -filetype=obj -triple=i686-pc-linux %S/Inputs/i386-static-tls-model4.s -o %t.o
# RUN: ld.lld %t.o -o %t4 -shared
# RUN: llvm-readobj -dynamic-table %t4 | FileCheck %s
# CHECK: DynamicSection [
# CHECK: FLAGS STATIC_TLS

View File

@ -13,8 +13,8 @@
// GOTRELSHARED-NEXT: SHF_ALLOC
// GOTRELSHARED-NEXT: SHF_WRITE
// GOTRELSHARED-NEXT: ]
// GOTRELSHARED-NEXT: Address: 0x1060
// GOTRELSHARED-NEXT: Offset: 0x1060
// GOTRELSHARED-NEXT: Address: 0x1058
// GOTRELSHARED-NEXT: Offset: 0x1058
// GOTRELSHARED-NEXT: Size: 16
// GOTRELSHARED-NEXT: Link: 0
// GOTRELSHARED-NEXT: Info: 0
@ -31,36 +31,36 @@
// GOTRELSHARED-NEXT: 0x202D R_386_RELATIVE - 0x0
// GOTRELSHARED-NEXT: 0x2036 R_386_RELATIVE - 0x0
// GOTRELSHARED-NEXT: 0x203F R_386_RELATIVE - 0x0
// GOTRELSHARED-NEXT: 0x1060 R_386_TLS_TPOFF tlslocal0 0x0
// GOTRELSHARED-NEXT: 0x1064 R_386_TLS_TPOFF tlslocal1 0x0
// GOTRELSHARED-NEXT: 0x1068 R_386_TLS_TPOFF tlsshared0 0x0
// GOTRELSHARED-NEXT: 0x106C R_386_TLS_TPOFF tlsshared1 0x0
// GOTRELSHARED-NEXT: 0x1058 R_386_TLS_TPOFF tlslocal0 0x0
// GOTRELSHARED-NEXT: 0x105C R_386_TLS_TPOFF tlslocal1 0x0
// GOTRELSHARED-NEXT: 0x1060 R_386_TLS_TPOFF tlsshared0 0x0
// GOTRELSHARED-NEXT: 0x1064 R_386_TLS_TPOFF tlsshared1 0x0
// GOTRELSHARED-NEXT: }
// GOTRELSHARED-NEXT: ]
// GOTRELSHARED: 0x6FFFFFFA RELCOUNT 8
// DISASMSHARED: Disassembly of section test:
// DISASMSHARED-NEXT: _start:
// (.got)[0] = 0x1060 = 4192
// (.got)[1] = 0x1064 = 4196
// (.got)[2] = 0x1068 = 4200
// (.got)[3] = 0x106C = 4204
// DISASMSHARED-NEXT: 2000: {{.*}} movl 4192, %ecx
// DISASMSHARED-NEXT: 2006: {{.*}} movl %gs:(%ecx), %eax
// DISASMSHARED-NEXT: 2009: {{.*}} movl 4192, %eax
// DISASMSHARED-NEXT: 200e: {{.*}} movl %gs:(%eax), %eax
// DISASMSHARED-NEXT: 2011: {{.*}} addl 4192, %ecx
// DISASMSHARED-NEXT: 2017: {{.*}} movl %gs:(%ecx), %eax
// DISASMSHARED-NEXT: 201a: {{.*}} movl 4196, %ecx
// DISASMSHARED-NEXT: 2020: {{.*}} movl %gs:(%ecx), %eax
// DISASMSHARED-NEXT: 2023: {{.*}} movl 4196, %eax
// DISASMSHARED-NEXT: 2028: {{.*}} movl %gs:(%eax), %eax
// DISASMSHARED-NEXT: 202b: {{.*}} addl 4196, %ecx
// DISASMSHARED-NEXT: 2031: {{.*}} movl %gs:(%ecx), %eax
// DISASMSHARED-NEXT: 2034: {{.*}} movl 4200, %ecx
// DISASMSHARED-NEXT: 203a: {{.*}} movl %gs:(%ecx), %eax
// DISASMSHARED-NEXT: 203d: {{.*}} addl 4204, %ecx
// DISASMSHARED-NEXT: 2043: {{.*}} movl %gs:(%ecx), %eax
// (.got)[0] = 0x2050 = 8272
// (.got)[1] = 0x2054 = 8276
// (.got)[2] = 0x2058 = 8280
// (.got)[3] = 0x205C = 8284
// DISASMSHARED-NEXT: 2000: 8b 0d 58 10 00 00 movl 4184, %ecx
// DISASMSHARED-NEXT: 2006: 65 8b 01 movl %gs:(%ecx), %eax
// DISASMSHARED-NEXT: 2009: a1 58 10 00 00 movl 4184, %eax
// DISASMSHARED-NEXT: 200e: 65 8b 00 movl %gs:(%eax), %eax
// DISASMSHARED-NEXT: 2011: 03 0d 58 10 00 00 addl 4184, %ecx
// DISASMSHARED-NEXT: 2017: 65 8b 01 movl %gs:(%ecx), %eax
// DISASMSHARED-NEXT: 201a: 8b 0d 5c 10 00 00 movl 4188, %ecx
// DISASMSHARED-NEXT: 2020: 65 8b 01 movl %gs:(%ecx), %eax
// DISASMSHARED-NEXT: 2023: a1 5c 10 00 00 movl 4188, %eax
// DISASMSHARED-NEXT: 2028: 65 8b 00 movl %gs:(%eax), %eax
// DISASMSHARED-NEXT: 202b: 03 0d 5c 10 00 00 addl 4188, %ecx
// DISASMSHARED-NEXT: 2031: 65 8b 01 movl %gs:(%ecx), %eax
// DISASMSHARED-NEXT: 2034: 8b 0d 60 10 00 00 movl 4192, %ecx
// DISASMSHARED-NEXT: 203a: 65 8b 01 movl %gs:(%ecx), %eax
// DISASMSHARED-NEXT: 203d: 03 0d 64 10 00 00 addl 4196, %ecx
// DISASMSHARED-NEXT: 2043: 65 8b 01 movl %gs:(%ecx), %eax
.type tlslocal0,@object
.section .tbss,"awT",@nobits

View File

@ -56,8 +56,8 @@ addl tls1@gotntpoff(%ebx),%eax
// CHECK-NEXT: SHF_ALLOC
// CHECK-NEXT: SHF_WRITE
// CHECK-NEXT: ]
// CHECK-NEXT: Address: 0x3070
// CHECK-NEXT: Offset: 0x3070
// CHECK-NEXT: Address: 0x3068
// CHECK-NEXT: Offset: 0x3068
// CHECK-NEXT: Size: 32
// CHECK-NEXT: Link: 0
// CHECK-NEXT: Info: 0
@ -66,13 +66,13 @@ addl tls1@gotntpoff(%ebx),%eax
// CHECK: Relocations [
// CHECK: Section ({{.+}}) .rel.dyn {
// CHECK-NEXT: 0x3080 R_386_TLS_DTPMOD32 - 0x0
// CHECK-NEXT: 0x3070 R_386_TLS_DTPMOD32 tls0 0x0
// CHECK-NEXT: 0x3074 R_386_TLS_DTPOFF32 tls0 0x0
// CHECK-NEXT: 0x3088 R_386_TLS_TPOFF tls0 0x0
// CHECK-NEXT: 0x3078 R_386_TLS_DTPMOD32 tls1 0x0
// CHECK-NEXT: 0x307C R_386_TLS_DTPOFF32 tls1 0x0
// CHECK-NEXT: 0x308C R_386_TLS_TPOFF tls1 0x0
// CHECK-NEXT: 0x3078 R_386_TLS_DTPMOD32 - 0x0
// CHECK-NEXT: 0x3068 R_386_TLS_DTPMOD32 tls0 0x0
// CHECK-NEXT: 0x306C R_386_TLS_DTPOFF32 tls0 0x0
// CHECK-NEXT: 0x3080 R_386_TLS_TPOFF tls0 0x0
// CHECK-NEXT: 0x3070 R_386_TLS_DTPMOD32 tls1 0x0
// CHECK-NEXT: 0x3074 R_386_TLS_DTPOFF32 tls1 0x0
// CHECK-NEXT: 0x3084 R_386_TLS_TPOFF tls1 0x0
// CHECK-NEXT: }
// DIS: Disassembly of section .text:
@ -80,20 +80,20 @@ addl tls1@gotntpoff(%ebx),%eax
// General dynamic model:
// -32 and -24 are first and second GOT entries offsets.
// Each one is a pair of records.
// DIS-NEXT: 1000: {{.*}} leal -32(,%ebx), %eax
// DIS-NEXT: 1007: {{.*}} calll 100
// DIS-NEXT: 100c: {{.*}} leal -24(,%ebx), %eax
// DIS-NEXT: 1013: {{.*}} calll 88
// DIS-NEXT: 1000: 8d 04 1d e0 ff ff ff leal -32(,%ebx), %eax
// DIS-NEXT: 1007: e8 64 00 00 00 calll 100
// DIS-NEXT: 100c: 8d 04 1d e8 ff ff ff leal -24(,%ebx), %eax
// DIS-NEXT: 1013: e8 58 00 00 00 calll 88
// Local dynamic model:
// -16 is a local module tls index offset.
// DIS-NEXT: 1018: {{.*}} leal -16(%ebx), %eax
// DIS-NEXT: 101e: {{.*}} calll 77
// DIS-NEXT: 1023: {{.*}} leal 8(%eax), %edx
// DIS-NEXT: 1029: {{.*}} leal -16(%ebx), %eax
// DIS-NEXT: 102f: {{.*}} calll 60
// DIS-NEXT: 1034: {{.*}} leal 12(%eax), %edx
// DIS-NEXT: 1018: 8d 83 f0 ff ff ff leal -16(%ebx), %eax
// DIS-NEXT: 101e: e8 4d 00 00 00 calll 77
// DIS-NEXT: 1023: 8d 90 08 00 00 00 leal 8(%eax), %edx
// DIS-NEXT: 1029: 8d 83 f0 ff ff ff leal -16(%ebx), %eax
// DIS-NEXT: 102f: e8 3c 00 00 00 calll 60
// DIS-NEXT: 1034: 8d 90 0c 00 00 00 leal 12(%eax), %edx
// Initial exec model:
// DIS-NEXT: 103a: {{.*}} movl %gs:0, %eax
// DIS-NEXT: 1040: {{.*}} addl -8(%ebx), %eax
// DIS-NEXT: 1046: {{.*}} movl %gs:0, %eax
// DIS-NEXT: 104c: {{.*}} addl -4(%ebx), %eax
// DIS-NEXT: 103a: 65 a1 00 00 00 00 movl %gs:0, %eax
// DIS-NEXT: 1040: 03 83 f8 ff ff ff addl -8(%ebx), %eax
// DIS-NEXT: 1046: 65 a1 00 00 00 00 movl %gs:0, %eax
// DIS-NEXT: 104c: 03 83 fc ff ff ff addl -4(%ebx), %eax

View File

@ -13,8 +13,8 @@
// GOTREL-NEXT: SHF_ALLOC
// GOTREL-NEXT: SHF_WRITE
// GOTREL-NEXT: ]
// GOTREL-NEXT: Address: 0x12060
// GOTREL-NEXT: Offset: 0x2060
// GOTREL-NEXT: Address: 0x12058
// GOTREL-NEXT: Offset: 0x2058
// GOTREL-NEXT: Size: 8
// GOTREL-NEXT: Link: 0
// GOTREL-NEXT: Info: 0
@ -23,8 +23,8 @@
// GOTREL-NEXT: }
// GOTREL: Relocations [
// GOTREL-NEXT: Section ({{.*}}) .rel.dyn {
// GOTREL-NEXT: 0x12060 R_386_TLS_TPOFF tlsshared0 0x0
// GOTREL-NEXT: 0x12064 R_386_TLS_TPOFF tlsshared1 0x0
// GOTREL-NEXT: 0x12058 R_386_TLS_TPOFF tlsshared0 0x0
// GOTREL-NEXT: 0x1205C R_386_TLS_TPOFF tlsshared1 0x0
// GOTREL-NEXT: }
// GOTREL-NEXT: ]
@ -32,24 +32,24 @@
// DISASM-NEXT: _start:
// 4294967288 = 0xFFFFFFF8
// 4294967292 = 0xFFFFFFFC
// 73824 = (.got)[0] = 0x12060
// 73828 = (.got)[1] = 0x12064
// DISASM-NEXT: 11000: {{.*}} movl $4294967288, %ecx
// DISASM-NEXT: 11006: {{.*}} movl %gs:(%ecx), %eax
// DISASM-NEXT: 11009: {{.*}} movl $4294967288, %eax
// DISASM-NEXT: 1100e: {{.*}} movl %gs:(%eax), %eax
// DISASM-NEXT: 11011: {{.*}} addl $4294967288, %ecx
// DISASM-NEXT: 11017: {{.*}} movl %gs:(%ecx), %eax
// DISASM-NEXT: 1101a: {{.*}} movl $4294967292, %ecx
// DISASM-NEXT: 11020: {{.*}} movl %gs:(%ecx), %eax
// DISASM-NEXT: 11023: {{.*}} movl $4294967292, %eax
// DISASM-NEXT: 11028: {{.*}} movl %gs:(%eax), %eax
// DISASM-NEXT: 1102b: {{.*}} addl $4294967292, %ecx
// DISASM-NEXT: 11031: {{.*}} movl %gs:(%ecx), %eax
// DISASM-NEXT: 11034: {{.*}} movl 73824, %ecx
// DISASM-NEXT: 1103a: {{.*}} movl %gs:(%ecx), %eax
// DISASM-NEXT: 1103d: {{.*}} addl 73828, %ecx
// DISASM-NEXT: 11043: {{.*}} movl %gs:(%ecx), %eax
// 73808 = (.got)[0] = 0x12058
// 73812 = (.got)[1] = 0x1205C
// DISASM-NEXT: 11000: c7 c1 f8 ff ff ff movl $4294967288, %ecx
// DISASM-NEXT: 11006: 65 8b 01 movl %gs:(%ecx), %eax
// DISASM-NEXT: 11009: b8 f8 ff ff ff movl $4294967288, %eax
// DISASM-NEXT: 1100e: 65 8b 00 movl %gs:(%eax), %eax
// DISASM-NEXT: 11011: 81 c1 f8 ff ff ff addl $4294967288, %ecx
// DISASM-NEXT: 11017: 65 8b 01 movl %gs:(%ecx), %eax
// DISASM-NEXT: 1101a: c7 c1 fc ff ff ff movl $4294967292, %ecx
// DISASM-NEXT: 11020: 65 8b 01 movl %gs:(%ecx), %eax
// DISASM-NEXT: 11023: b8 fc ff ff ff movl $4294967292, %eax
// DISASM-NEXT: 11028: 65 8b 00 movl %gs:(%eax), %eax
// DISASM-NEXT: 1102b: 81 c1 fc ff ff ff addl $4294967292, %ecx
// DISASM-NEXT: 11031: 65 8b 01 movl %gs:(%ecx), %eax
// DISASM-NEXT: 11034: 8b 0d 58 20 01 00 movl 73816, %ecx
// DISASM-NEXT: 1103a: 65 8b 01 movl %gs:(%ecx), %eax
// DISASM-NEXT: 1103d: 03 0d 5c 20 01 00 addl 73820, %ecx
// DISASM-NEXT: 11043: 65 8b 01 movl %gs:(%ecx), %eax
.type tlslocal0,@object
.section .tbss,"awT",@nobits