]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/ELF/arm-tls-le32.s
Vendor import of lld trunk r338150:
[FreeBSD/FreeBSD.git] / test / ELF / arm-tls-le32.s
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
6
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
10
11  .text
12  .syntax unified
13  .globl  _start
14  .p2align        2
15  .type   _start,%function
16 _start:
17  .p2align        2
18 // Generate R_ARM_TLS_LE32 relocations. These resolve statically to the offset
19 // of the variable from the thread pointer
20 .Lt0: .word   x(TPOFF)
21 .Lt1: .word   y(TPOFF)
22 .Lt2: .word   z(TPOFF)
23
24 // __thread int x = 10
25 // __thread int y;
26 // __thread int z __attribute((visibility("hidden")))
27
28  .hidden z
29  .globl  z
30  .globl  y
31  .globl  x
32
33  .section       .tbss,"awT",%nobits
34  .p2align  2
35 .TLSSTART:
36  .type  z, %object
37 z:
38  .space 4
39  .type  y, %object
40 y:
41  .space 4
42  .section       .tdata,"awT",%progbits
43  .p2align 2
44  .type  x, %object
45 x:
46  .word  10
47
48 // SEC:      Name: .tdata
49 // SEC-NEXT: Type: SHT_PROGBITS
50 // SEC-NEXT: Flags [
51 // SEC-NEXT:   SHF_ALLOC
52 // SEC-NEXT:   SHF_TLS
53 // SEC-NEXT:   SHF_WRITE
54 // SEC-NEXT:  ]
55 // SEC-NEXT: Address: 0x12000
56 // SEC:      Size: 4
57 // SEC:      Name: .tbss
58 // SEC-NEXT: Type: SHT_NOBITS
59 // SEC-NEXT: Flags [
60 // SEC-NEXT:   SHF_ALLOC
61 // SEC-NEXT:   SHF_TLS
62 // SEC-NEXT:   SHF_WRITE
63 // SEC-NEXT: ]
64 // SEC-NEXT: Address: 0x12004
65 // SEC:      Size: 8
66
67 // SEC: Dynamic Relocations {
68 // SEC-NEXT: }
69
70 // CHECK: Disassembly of section .text:
71 // CHECK-NEXT: _start:
72 // offset of x from Thread pointer = (TcbSize + 0x0 = 0x8)
73 // CHECK-NEXT:   11000:         08 00 00 00
74 // offset of z from Thread pointer = (TcbSize + 0x8 = 0x10)
75 // CHECK-NEXT:   11004:         10 00 00 00
76 // offset of y from Thread pointer = (TcbSize + 0x4 = 0xc)
77 // CHECK-NEXT:   11008:         0c 00 00 00