Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lld / test / ELF / arm-tls-le32.s
bloba4540382cad621b28d79a85ccecd775614166a6c
1 // REQUIRES: arm
2 // RUN: llvm-mc %s -o %t.o -filetype=obj -triple=armv7a-linux-gnueabi
3 // RUN: ld.lld %t.o -o %t
4 // RUN: llvm-readobj -S --dyn-relocations %t | FileCheck --check-prefix=SEC %s
5 // RUN: llvm-objdump -d --triple=armv7a-linux-gnueabi %t | FileCheck %s
7 /// Test the handling of the local exec TLS model. TLS can be resolved
8 /// statically for an application. The code sequences assume a thread pointer
9 /// in r9
11 /// Reject local-exec TLS relocations for -shared.
12 // RUN: not ld.lld -shared %t.o -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR --implicit-check-not=error:
14 // ERR: error: relocation R_ARM_TLS_LE32 against x cannot be used with -shared
15 // ERR: error: relocation R_ARM_TLS_LE32 against y cannot be used with -shared
16 // ERR: error: relocation R_ARM_TLS_LE32 against z cannot be used with -shared
18 .text
19 .syntax unified
20 .globl _start
21 .p2align 2
22 .type _start,%function
23 _start:
24 .p2align 2
25 /// Generate R_ARM_TLS_LE32 relocations. These resolve statically to the offset
26 /// of the variable from the thread pointer
27 .Lt0: .word x(TPOFF)
28 .Lt1: .word y(TPOFF)
29 .Lt2: .word z(TPOFF)
31 /// __thread int x = 10
32 /// __thread int y;
33 /// __thread int z __attribute((visibility("hidden")))
35 .hidden z
36 .globl z
37 .globl y
38 .globl x
40 .section .tbss,"awT",%nobits
41 .p2align 2
42 .TLSSTART:
43 .type z, %object
45 .space 4
46 .type y, %object
48 .space 4
49 .section .tdata,"awT",%progbits
50 .p2align 2
51 .type x, %object
53 .word 10
55 // SEC: Name: .tdata
56 // SEC-NEXT: Type: SHT_PROGBITS
57 // SEC-NEXT: Flags [
58 // SEC-NEXT: SHF_ALLOC
59 // SEC-NEXT: SHF_TLS
60 // SEC-NEXT: SHF_WRITE
61 // SEC-NEXT: ]
62 // SEC-NEXT: Address: 0x30120
63 // SEC: Size: 4
64 // SEC: Name: .tbss
65 // SEC-NEXT: Type: SHT_NOBITS
66 // SEC-NEXT: Flags [
67 // SEC-NEXT: SHF_ALLOC
68 // SEC-NEXT: SHF_TLS
69 // SEC-NEXT: SHF_WRITE
70 // SEC-NEXT: ]
71 // SEC-NEXT: Address: 0x30124
72 // SEC: Size: 8
74 // SEC: Dynamic Relocations {
75 // SEC-NEXT: }
77 // CHECK: Disassembly of section .text:
78 // CHECK-EMPTY:
79 // CHECK-NEXT: <_start>:
80 /// offset of x from Thread pointer = (TcbSize + 0x0 = 0x8)
81 // CHECK-NEXT: 20114: 00000008
82 /// offset of z from Thread pointer = (TcbSize + 0x8 = 0x10)
83 // CHECK-NEXT: 20118: 00000010
84 /// offset of y from Thread pointer = (TcbSize + 0x4 = 0xc)
85 // CHECK-NEXT: 2011c: 0000000c