blob: 5cf5429bbb3d9f1c70082218d3887f906f9b2630 [file] [log] [blame]
Fangrui Songb6772b82018-06-26 22:20:041// REQUIRES: arm
Peter Smith9d450252016-07-20 08:52:272// RUN: llvm-mc %s -o %t.o -filetype=obj -triple=armv7a-linux-gnueabi
Fangrui Song024bf27d2019-08-27 11:52:363// RUN: ld.lld %t.o -o %t.so -shared
Fangrui Songb1599062019-05-01 05:49:014// RUN: llvm-readobj -S --dyn-relocations %t.so | FileCheck --check-prefix=SEC %s
Peter Smith9d450252016-07-20 08:52:275// RUN: llvm-objdump -d -triple=armv7a-linux-gnueabi %t.so | FileCheck %s
Peter Smith9d450252016-07-20 08:52:276
7// Test the handling of the global-dynamic TLS model. Dynamic Loader finds
8// module index R_ARM_TLS_DTPMOD32 and the offset within the module
9// R_ARM_TLS_DTPOFF32. One of the variables is hidden which permits relaxation
10// to local dynamic
11
12 .text
13 .syntax unified
14 .globl func
15 .p2align 2
16 .type func,%function
17func:
18.L0:
19 nop
20.L1:
21 nop
22.L2:
23 nop
24
25 .p2align 2
26// Generate R_ARM_TLS_GD32 relocations
27// Allocates a pair of GOT entries dynamically relocated by R_ARM_TLS_DTPMOD32
28// and R_ARM_TLS_DTPOFF32 respectively. The literal contains the offset of the
29// first GOT entry from the place
30.Lt0: .word x(TLSGD) + (. - .L0 - 8)
31.Lt1: .word y(TLSGD) + (. - .L1 - 8)
32.Lt2: .word z(TLSGD) + (. - .L2 - 8)
33
34// __thread int x = 10
35// __thread int y;
36// __thread int z __attribute((visibility("hidden")))
37
38 .hidden z
39 .globl z
40 .globl y
41 .globl x
42
43 .section .tbss,"awT",%nobits
44 .p2align 2
45.TLSSTART:
46 .type z, %object
47z:
48 .space 4
49 .type y, %object
50y:
51 .space 4
52 .section .tdata,"awT",%progbits
53 .p2align 2
54 .type x, %object
55x:
56 .word 10
57
58// SEC: Name: .tdata
59// SEC-NEXT: Type: SHT_PROGBITS
60// SEC-NEXT: Flags [
61// SEC-NEXT: SHF_ALLOC
62// SEC-NEXT: SHF_TLS
63// SEC-NEXT: SHF_WRITE
64// SEC-NEXT: ]
Fangrui Song024bf27d2019-08-27 11:52:3665// SEC-NEXT: Address: 0x2210
Peter Smith9d450252016-07-20 08:52:2766// SEC: Size: 4
67// SEC: Name: .tbss
68// SEC-NEXT: Type: SHT_NOBITS
69// SEC-NEXT: Flags [
70// SEC-NEXT: SHF_ALLOC
71// SEC-NEXT: SHF_TLS
72// SEC-NEXT: SHF_WRITE
73// SEC-NEXT: ]
Fangrui Song024bf27d2019-08-27 11:52:3674// SEC-NEXT: Address: 0x2214
Peter Smith9d450252016-07-20 08:52:2775// SEC: Size: 8
76
77// SEC: Name: .got
78// SEC-NEXT: Type: SHT_PROGBITS
79// SEC-NEXT: Flags [
80// SEC-NEXT: SHF_ALLOC
81// SEC-NEXT: SHF_WRITE
82// SEC-NEXT: ]
Fangrui Song024bf27d2019-08-27 11:52:3683// SEC-NEXT: Address: 0x2264
Peter Smith9d450252016-07-20 08:52:2784// SEC: Size: 24
85
86// SEC: Dynamic Relocations {
Fangrui Song024bf27d2019-08-27 11:52:3687// SEC-NEXT: 0x2274 R_ARM_TLS_DTPMOD32 -
88// SEC-NEXT: 0x2264 R_ARM_TLS_DTPMOD32 x
89// SEC-NEXT: 0x2268 R_ARM_TLS_DTPOFF32 x
90// SEC-NEXT: 0x226C R_ARM_TLS_DTPMOD32 y
91// SEC-NEXT: 0x2270 R_ARM_TLS_DTPOFF32 y
Peter Smith9d450252016-07-20 08:52:2792
93
Fangrui Song024bf27d2019-08-27 11:52:3694// CHECK-LABEL: 000011f8 func:
95// CHECK-NEXT: 11f8: 00 f0 20 e3 nop
96// CHECK-NEXT: 11fc: 00 f0 20 e3 nop
97// CHECK-NEXT: 1200: 00 f0 20 e3 nop
Peter Smith9d450252016-07-20 08:52:2798
Fangrui Song024bf27d2019-08-27 11:52:3699// (0x2264 - 0x1204) + (0x1204 - 0x11f8 - 8) = 0x1064
100// CHECK: 1204: 64 10 00 00
101// (0x226c - 0x1204) + (0x1204 - 0x11fc - 8) = 0x1068
102// CHECK-NEXT: 1208: 68 10 00 00
103// (0x2274 - 0x1204) + (0x1204 - 0x1200 - 8) = 0x106c
104// CHECK-NEXT: 120c: 6c 10 00 00
Peter Smith9d450252016-07-20 08:52:27105