File: arm-tls-le32.s

package info (click to toggle)
llvm-toolchain-11 1%3A11.0.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 995,808 kB
  • sloc: cpp: 4,767,656; ansic: 760,916; asm: 477,436; python: 170,940; objc: 69,804; lisp: 29,914; sh: 23,855; f90: 18,173; pascal: 7,551; perl: 7,471; ml: 5,603; awk: 3,489; makefile: 2,573; xml: 915; cs: 573; fortran: 503; javascript: 452
file content (78 lines) | stat: -rw-r--r-- 1,960 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// REQUIRES: arm
// RUN: llvm-mc %s -o %t.o -filetype=obj -triple=armv7a-linux-gnueabi
// RUN: ld.lld %t.o -o %t
// RUN: llvm-readobj -S --dyn-relocations %t | FileCheck --check-prefix=SEC %s
// RUN: llvm-objdump -d --triple=armv7a-linux-gnueabi %t | FileCheck %s

/// Test the handling of the local exec TLS model. TLS can be resolved
/// statically for an application. The code sequences assume a thread pointer
/// in r9

 .text
 .syntax unified
 .globl  _start
 .p2align        2
 .type   _start,%function
_start:
 .p2align        2
/// Generate R_ARM_TLS_LE32 relocations. These resolve statically to the offset
/// of the variable from the thread pointer
.Lt0: .word   x(TPOFF)
.Lt1: .word   y(TPOFF)
.Lt2: .word   z(TPOFF)

/// __thread int x = 10
/// __thread int y;
/// __thread int z __attribute((visibility("hidden")))

 .hidden z
 .globl  z
 .globl  y
 .globl  x

 .section       .tbss,"awT",%nobits
 .p2align  2
.TLSSTART:
 .type  z, %object
z:
 .space 4
 .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: 0x30120
// SEC:      Size: 4
// SEC:      Name: .tbss
// SEC-NEXT: Type: SHT_NOBITS
// SEC-NEXT: Flags [
// SEC-NEXT:   SHF_ALLOC
// SEC-NEXT:   SHF_TLS
// SEC-NEXT:   SHF_WRITE
// SEC-NEXT: ]
// SEC-NEXT: Address: 0x30124
// SEC:      Size: 8

// SEC: Dynamic Relocations {
// SEC-NEXT: }

// CHECK: Disassembly of section .text:
// CHECK-EMPTY:
// CHECK-NEXT: <_start>:
/// offset of x from Thread pointer = (TcbSize + 0x0 = 0x8)
// CHECK-NEXT:   20114:         08 00 00 00
/// offset of z from Thread pointer = (TcbSize + 0x8 = 0x10)
// CHECK-NEXT:   20118:         10 00 00 00
/// offset of y from Thread pointer = (TcbSize + 0x4 = 0xc)
// CHECK-NEXT:   2011c:         0c 00 00 00