]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/ELF/arm-tls-ie32.s
Vendor import of lld trunk r338150:
[FreeBSD/FreeBSD.git] / test / ELF / arm-tls-ie32.s
1 // REQUIRES: arm
2 // RUN: llvm-mc %s -o %t.o -filetype=obj -triple=armv7a-linux-gnueabi
3 // RUN: ld.lld --hash-style=sysv %t.o -o %t.so -shared
4 // RUN: llvm-readobj -s -dyn-relocations %t.so | FileCheck --check-prefix=SEC %s
5 // RUN: llvm-objdump -d -triple=armv7a-linux-gnueabi %t.so | FileCheck %s
6
7 // Test the handling of the initial-exec TLS model. Relative location within
8 // static TLS is a run-time constant computed by dynamic loader as a result
9 // of the R_ARM_TLS_TPOFF32 relocation.
10
11  .syntax unified
12  .arm
13  .globl func
14  .type  func,%function
15  .p2align 2
16 func:
17 .L0:
18  nop
19 .L1:
20  nop
21 .L2:
22  nop
23
24  .p2align 2
25 // Generate R_ARM_TLS_IE32 static relocations
26 // Allocates a GOT entry dynamically relocated by R_ARM_TLS_TPOFF32
27 // literal contains the offset of the GOT entry from the place
28 .Lt0: .word  x(gottpoff) + (. - .L0 - 8)
29 .Lt1: .word  y(gottpoff) + (. - .L1 - 8)
30 .Lt2: .word  .TLSSTART(gottpoff) + (. - .L2 - 8)
31
32 // __thread int x = 10
33 // __thread int y;
34 // __thread int z __attribute((visibility("hidden")))
35  .hidden z
36  .globl  z
37  .globl  y
38  .globl  x
39
40  .section       .tbss,"awT",%nobits
41  .p2align  2
42 .TLSSTART:
43  .type  z, %object
44 z:
45  .space 4
46  .type  y, %object
47 y:
48  .space 4
49  .section       .tdata,"awT",%progbits
50  .p2align 2
51  .type  x, %object
52 x:
53  .word  10
54
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:      Size: 4
62 // SEC:      Name: .tbss
63 // SEC-NEXT: Type: SHT_NOBITS
64 // SEC-NEXT: Flags [
65 // SEC-NEXT:   SHF_ALLOC
66 // SEC-NEXT:   SHF_TLS
67 // SEC-NEXT:   SHF_WRITE
68 // SEC: Size: 8
69
70 // SEC:      Name: .got
71 // SEC-NEXT: Type: SHT_PROGBITS
72 // SEC-NEXT: Flags [
73 // SEC-NEXT:    SHF_ALLOC
74 // SEC-NEXT:    SHF_WRITE
75 // SEC-NEXT: ]
76 // SEC-NEXT: Address: 0x204C
77 // SEC:      Size: 12
78
79
80 // SEC: Dynamic Relocations {
81 // SEC:  0x2054 R_ARM_TLS_TPOFF32
82 // SEC:  0x204C R_ARM_TLS_TPOFF32 x
83 // SEC:  0x2050 R_ARM_TLS_TPOFF32 y
84
85 // CHECK: Disassembly of section .text:
86 // CHECK-NEXT: func:
87 // CHECK-NEXT:    1000: 00 f0 20 e3     nop
88 // CHECK-NEXT:    1004: 00 f0 20 e3     nop
89 // CHECK-NEXT:    1008: 00 f0 20 e3     nop
90
91 // (0x204c - 0x100c) + (0x100c - 0x1000 - 8) = 0x1044
92 // CHECK:         100c: 44 10 00 00
93 // (0x2050 - 0x1010) + (0x1010 - 0x1004 - 8) = 0x1044
94 // CHECK-NEXT:    1010: 44 10 00 00
95 // (0x2054 - 0x1014) + (0x1014 - 0x1008 - 8) = 0x1044
96 // CHECK-NEXT:    1014: 44 10 00 00