2018-06-27 06:20:04 +08:00
|
|
|
// REQUIRES: arm
|
2016-07-20 22:56:26 +08:00
|
|
|
// RUN: llvm-mc %s -o %t.o -filetype=obj -triple=armv7a-linux-gnueabi
|
2017-10-06 17:37:44 +08:00
|
|
|
// RUN: ld.lld --hash-style=sysv %t.o -o %t.so -shared
|
2019-05-01 13:49:01 +08:00
|
|
|
// RUN: llvm-readobj -S --dyn-relocations %t.so | FileCheck --check-prefix=SEC %s
|
2016-07-20 22:56:26 +08:00
|
|
|
// RUN: llvm-objdump -d -triple=armv7a-linux-gnueabi %t.so | FileCheck %s
|
2019-08-27 19:50:27 +08:00
|
|
|
// RUN: ld.lld %t.o -o %t
|
|
|
|
// RUN: llvm-objdump -d -triple=armv7a-linux-gnueabi %t | FileCheck --check-prefix=CHECK-EXE %s
|
2016-07-20 22:56:26 +08:00
|
|
|
|
|
|
|
// Test the handling of the local-dynamic TLS model. Dynamic loader finds
|
|
|
|
// module index R_ARM_TLS_DTPMOD32. The offset in the next GOT slot is 0
|
|
|
|
// The R_ARM_TLS_LDO is the offset of the variable within the TLS block.
|
|
|
|
.global __tls_get_addr
|
|
|
|
.text
|
|
|
|
.p2align 2
|
|
|
|
.global _start
|
|
|
|
.syntax unified
|
|
|
|
.arm
|
|
|
|
.type _start, %function
|
|
|
|
_start:
|
|
|
|
.L0:
|
|
|
|
nop
|
|
|
|
|
|
|
|
.word x(tlsldm) + (. - .L0 - 8)
|
|
|
|
.word x(tlsldo)
|
|
|
|
.word y(tlsldo)
|
|
|
|
|
|
|
|
.section .tbss,"awT",%nobits
|
|
|
|
.p2align 2
|
|
|
|
.type y, %object
|
|
|
|
y:
|
|
|
|
.space 4
|
|
|
|
.section .tdata,"awT",%progbits
|
|
|
|
.p2align 2
|
|
|
|
.type x, %object
|
|
|
|
x:
|
|
|
|
.word 10
|
|
|
|
|
|
|
|
// SEC: Name: .tdata
|
|
|
|
// SEC-NEXT: Type: SHT_PROGBITS
|
|
|
|
// SEC-NEXT: Flags [
|
|
|
|
// SEC-NEXT: SHF_ALLOC
|
|
|
|
// SEC-NEXT: SHF_TLS
|
|
|
|
// SEC-NEXT: SHF_WRITE
|
|
|
|
// SEC-NEXT: ]
|
|
|
|
// SEC-NEXT: Address: 0x2000
|
|
|
|
// SEC: Size: 4
|
|
|
|
// SEC: Name: .tbss
|
|
|
|
// SEC-NEXT: Type: SHT_NOBITS (0x8)
|
|
|
|
// SEC-NEXT: Flags [
|
|
|
|
// SEC-NEXT: SHF_ALLOC
|
|
|
|
// SEC-NEXT: SHF_TLS
|
|
|
|
// SEC-NEXT: SHF_WRITE
|
|
|
|
// SEC-NEXT: ]
|
|
|
|
// SEC-NEXT: Address: 0x2004
|
|
|
|
// SEC: Size: 4
|
|
|
|
|
|
|
|
// SEC: Dynamic Relocations {
|
|
|
|
// SEC-NEXT: 0x204C R_ARM_TLS_DTPMOD32 - 0x0
|
|
|
|
|
|
|
|
// CHECK: Disassembly of section .text:
|
2019-05-01 18:40:48 +08:00
|
|
|
// CHECK-EMPTY:
|
2016-07-20 22:56:26 +08:00
|
|
|
// CHECK-NEXT: _start:
|
|
|
|
// CHECK-NEXT: 1000: 00 f0 20 e3 nop
|
|
|
|
|
|
|
|
// (0x204c - 0x1004) + (0x1004 - 0x1000 - 8) = 0x1044
|
|
|
|
// CHECK: 1004: 44 10 00 00
|
|
|
|
// CHECK-NEXT: 1008: 00 00 00 00
|
|
|
|
// CHECK-NEXT: 100c: 04 00 00 00
|
|
|
|
|
2019-08-27 19:50:27 +08:00
|
|
|
// CHECK-EXE: _start:
|
|
|
|
// CHECK-EXE-NEXT: 11000: 00 f0 20 e3 nop
|
|
|
|
// CHECK-EXE: 11004: fc 0f 00 00
|
|
|
|
// CHECK-EXE-NEXT: 11008: 00 00 00 00
|
|
|
|
// CHECK-EXE-NEXT: 1100c: 04 00 00 00
|