forked from OSchip/llvm-project
[ELF] Set DF_STATIC_TLS for AArch64/PPC32/PPC64
This commit is contained in:
parent
8800869337
commit
2b153088be
|
@ -145,7 +145,6 @@ RelExpr Hexagon::getRelExpr(RelType type, const Symbol &s,
|
|||
case R_HEX_IE_GOT_32_6_X:
|
||||
case R_HEX_IE_GOT_HI16:
|
||||
case R_HEX_IE_GOT_LO16:
|
||||
config->hasTlsIe = true;
|
||||
return R_GOTPLT;
|
||||
case R_HEX_TPREL_11_X:
|
||||
case R_HEX_TPREL_16:
|
||||
|
|
|
@ -284,7 +284,6 @@ RelExpr RISCV::getRelExpr(const RelType type, const Symbol &s,
|
|||
case R_RISCV_TLS_GD_HI20:
|
||||
return R_TLSGD_PC;
|
||||
case R_RISCV_TLS_GOT_HI20:
|
||||
config->hasTlsIe = true;
|
||||
return R_GOT_PC;
|
||||
case R_RISCV_TPREL_HI20:
|
||||
case R_RISCV_TPREL_LO12_I:
|
||||
|
|
|
@ -77,9 +77,6 @@ int X86::getTlsGdRelaxSkip(RelType type) const {
|
|||
|
||||
RelExpr X86::getRelExpr(RelType type, const Symbol &s,
|
||||
const uint8_t *loc) const {
|
||||
if (type == R_386_TLS_IE || type == R_386_TLS_GOTIE)
|
||||
config->hasTlsIe = true;
|
||||
|
||||
switch (type) {
|
||||
case R_386_8:
|
||||
case R_386_16:
|
||||
|
|
|
@ -317,9 +317,6 @@ bool X86_64::deleteFallThruJmpInsn(InputSection &is, InputFile *file,
|
|||
|
||||
RelExpr X86_64::getRelExpr(RelType type, const Symbol &s,
|
||||
const uint8_t *loc) const {
|
||||
if (type == R_X86_64_GOTTPOFF)
|
||||
config->hasTlsIe = true;
|
||||
|
||||
switch (type) {
|
||||
case R_X86_64_8:
|
||||
case R_X86_64_16:
|
||||
|
|
|
@ -436,6 +436,8 @@ struct Ctx {
|
|||
backwardReferences;
|
||||
// True if SHT_LLVM_SYMPART is used.
|
||||
std::atomic<bool> hasSympart{false};
|
||||
// True if there are TLS IE relocations. Set DF_STATIC_TLS if -shared.
|
||||
std::atomic<bool> hasTlsIe{false};
|
||||
// True if we need to reserve two .got entries for local-dynamic TLS model.
|
||||
std::atomic<bool> needsTlsLd{false};
|
||||
|
||||
|
|
|
@ -1283,6 +1283,7 @@ static unsigned handleTlsRelocation(RelType type, Symbol &sym,
|
|||
|
||||
if (oneof<R_GOT, R_GOTPLT, R_GOT_PC, R_AARCH64_GOT_PAGE_PC, R_GOT_OFF,
|
||||
R_TLSIE_HINT>(expr)) {
|
||||
ctx.hasTlsIe.store(true, std::memory_order_relaxed);
|
||||
// Initial-Exec relocs can be relaxed to Local-Exec if the symbol is locally
|
||||
// defined.
|
||||
if (toExecRelax && isLocalInExecutable) {
|
||||
|
|
|
@ -1348,7 +1348,7 @@ DynamicSection<ELFT>::computeContents() {
|
|||
}
|
||||
if (!config->zText)
|
||||
dtFlags |= DF_TEXTREL;
|
||||
if (config->hasTlsIe && config->shared)
|
||||
if (ctx.hasTlsIe && config->shared)
|
||||
dtFlags |= DF_STATIC_TLS;
|
||||
|
||||
if (dtFlags)
|
||||
|
|
|
@ -8,15 +8,16 @@
|
|||
# RUN: llvm-readobj -d -r %t | FileCheck %s --check-prefix=LE-REL
|
||||
# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s --check-prefix=LE
|
||||
|
||||
# IE-REL: FLAGS STATIC_TLS
|
||||
# IE-REL: .rela.dyn {
|
||||
# IE-REL-NEXT: 0x20380 R_AARCH64_TLS_TPREL64 - 0xC
|
||||
# IE-REL-NEXT: 0x20378 R_AARCH64_TLS_TPREL64 a 0x0
|
||||
# IE-REL-NEXT: 0x20390 R_AARCH64_TLS_TPREL64 - 0xC
|
||||
# IE-REL-NEXT: 0x20388 R_AARCH64_TLS_TPREL64 a 0x0
|
||||
# IE-REL-NEXT: }
|
||||
|
||||
# IE: adrp x0, 0x20000
|
||||
# IE-NEXT: ldr x0, [x0, #0x378]
|
||||
# IE-NEXT: ldr x0, [x0, #0x388]
|
||||
# IE-NEXT: adrp x1, 0x20000
|
||||
# IE-NEXT: ldr x1, [x1, #0x380]
|
||||
# IE-NEXT: ldr x1, [x1, #0x390]
|
||||
|
||||
# LE-REL-NOT: FLAGS
|
||||
# LE-REL: Relocations [
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// REQUIRES: arm
|
||||
// RUN: llvm-mc %s -o %t.o -filetype=obj -triple=armv7a-linux-gnueabi
|
||||
// RUN: ld.lld %t.o -o %t.so -shared
|
||||
// RUN: llvm-readobj -S --dyn-relocations %t.so | FileCheck --check-prefix=SEC %s
|
||||
// RUN: llvm-readobj -S -d --dyn-relocations %t.so | FileCheck --check-prefix=SEC %s
|
||||
// RUN: llvm-objdump -d --triple=armv7a-linux-gnueabi %t.so | FileCheck %s
|
||||
|
||||
/// Test the handling of the initial-exec TLS model. Relative location within
|
||||
|
@ -73,14 +73,15 @@ x:
|
|||
// SEC-NEXT: SHF_ALLOC
|
||||
// SEC-NEXT: SHF_WRITE
|
||||
// SEC-NEXT: ]
|
||||
// SEC-NEXT: Address: 0x20254
|
||||
// SEC-NEXT: Address: 0x2025C
|
||||
// SEC: Size: 12
|
||||
|
||||
|
||||
// SEC: FLAGS STATIC_TLS
|
||||
// SEC: Dynamic Relocations {
|
||||
// SEC: 0x2025C R_ARM_TLS_TPOFF32
|
||||
// SEC: 0x20254 R_ARM_TLS_TPOFF32 x
|
||||
// SEC: 0x20258 R_ARM_TLS_TPOFF32 y
|
||||
// SEC: 0x20264 R_ARM_TLS_TPOFF32
|
||||
// SEC: 0x2025C R_ARM_TLS_TPOFF32 x
|
||||
// SEC: 0x20260 R_ARM_TLS_TPOFF32 y
|
||||
|
||||
// CHECK: Disassembly of section .text:
|
||||
// CHECK-EMPTY:
|
||||
|
@ -89,9 +90,9 @@ x:
|
|||
// CHECK-NEXT: 101ec: e320f000 nop
|
||||
// CHECK-NEXT: 101f0: e320f000 nop
|
||||
|
||||
/// (0x20254 - 0x101f4) + (0x101f4 - 0x101e8 - 8) = 0x10064
|
||||
// CHECK: 101f4: 64 00 01 00
|
||||
/// (0x20258 - 0x101f8) + (0x101f8 - 0x101ec - 8) = 0x10064
|
||||
// CHECK-NEXT: 101f8: 64 00 01 00
|
||||
/// (0x2025c - 0x101f8) + (0x101f8 - 0x101f0 - 8) = 0x10064
|
||||
// CHECK-NEXT: 101fc: 64 00 01 00
|
||||
/// (0x20264 - 0x101f4) + (0x101f4 - 0x101e8 - 8) = 0x1006c
|
||||
// CHECK: 101f4: 6c 00 01 00
|
||||
/// (0x2025C - 0x101f8) + (0x101f8 - 0x101ec - 8) = 0x1006c
|
||||
// CHECK-NEXT: 101f8: 6c 00 01 00
|
||||
/// (0x20260 - 0x101f8) + (0x101f8 - 0x101f0 - 8) = 0x1006c
|
||||
// CHECK-NEXT: 101fc: 6c 00 01 00
|
||||
|
|
|
@ -2,17 +2,18 @@
|
|||
# RUN: llvm-mc -filetype=obj -triple=powerpc %s -o %t.o
|
||||
|
||||
# RUN: ld.lld -shared %t.o -o %t.so
|
||||
# RUN: llvm-readobj -r %t.so | FileCheck --check-prefix=IE-REL %s
|
||||
# RUN: llvm-readobj -d -r %t.so | FileCheck --check-prefix=IE-REL %s
|
||||
# RUN: llvm-objdump -d --no-show-raw-insn %t.so | FileCheck --check-prefix=IE %s
|
||||
|
||||
# RUN: ld.lld %t.o -o %t
|
||||
# RUN: llvm-readelf -r %t | FileCheck --check-prefix=NOREL %s
|
||||
# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefix=LE %s
|
||||
|
||||
# IE-REL: FLAGS STATIC_TLS
|
||||
## A non-preemptable symbol (b) has 0 st_shndx.
|
||||
# IE-REL: .rela.dyn {
|
||||
# IE-REL-NEXT: 0x20230 R_PPC_TPREL32 - 0xC
|
||||
# IE-REL-NEXT: 0x2022C R_PPC_TPREL32 a 0x0
|
||||
# IE-REL-NEXT: 0x20238 R_PPC_TPREL32 - 0xC
|
||||
# IE-REL-NEXT: 0x20234 R_PPC_TPREL32 a 0x0
|
||||
# IE-REL-NEXT: }
|
||||
|
||||
## &.got[3] - _GLOBAL_OFFSET_TABLE_ = 12
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
# RUN: llvm-readobj -r %t.o | FileCheck --check-prefix=INPUT-REL %s
|
||||
## IE
|
||||
# RUN: ld.lld -shared %t.o -o %t.so
|
||||
# RUN: llvm-readobj -r %t.so | FileCheck --check-prefix=IE-REL %s
|
||||
# RUN: llvm-readobj -d -r %t.so | FileCheck --check-prefix=IE-REL %s
|
||||
# RUN: llvm-objdump -d --no-show-raw-insn %t.so | FileCheck --check-prefix=IE %s
|
||||
## IE -> LE
|
||||
# RUN: ld.lld %t.o -o %t
|
||||
|
@ -15,18 +15,19 @@
|
|||
# RUN: llvm-readobj -r %t.o | FileCheck --check-prefix=INPUT-REL %s
|
||||
## IE
|
||||
# RUN: ld.lld -shared %t.o -o %t.so
|
||||
# RUN: llvm-readobj -r %t.so | FileCheck --check-prefix=IE-REL %s
|
||||
# RUN: llvm-readobj -d -r %t.so | FileCheck --check-prefix=IE-REL %s
|
||||
# RUN: llvm-objdump -d --no-show-raw-insn %t.so | FileCheck --check-prefix=IE %s
|
||||
## IE -> LE
|
||||
# RUN: ld.lld %t.o -o %t
|
||||
# RUN: llvm-readelf -r %t | FileCheck --check-prefix=NOREL %s
|
||||
# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefix=LE %s
|
||||
|
||||
# IE-REL: FLAGS STATIC_TLS
|
||||
# IE-REL: .rela.dyn {
|
||||
# IE-REL-NEXT: 0x204A8 R_PPC64_TPREL64 c 0x0
|
||||
# IE-REL-NEXT: 0x204B0 R_PPC64_TPREL64 s 0x0
|
||||
# IE-REL-NEXT: 0x204B8 R_PPC64_TPREL64 i 0x0
|
||||
# IE-REL-NEXT: 0x204C0 R_PPC64_TPREL64 l 0x0
|
||||
# IE-REL-NEXT: 0x204B8 R_PPC64_TPREL64 c 0x0
|
||||
# IE-REL-NEXT: 0x204C0 R_PPC64_TPREL64 s 0x0
|
||||
# IE-REL-NEXT: 0x204C8 R_PPC64_TPREL64 i 0x0
|
||||
# IE-REL-NEXT: 0x204D0 R_PPC64_TPREL64 l 0x0
|
||||
# IE-REL-NEXT: }
|
||||
|
||||
# INPUT-REL: R_PPC64_GOT_TPREL16_HA c 0x0
|
||||
|
|
Loading…
Reference in New Issue