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 37z: 38 .space 4 39 .type y, %object 40y: 41 .space 4 42 .section .tdata,"awT",%progbits 43 .p2align 2 44 .type x, %object 45x: 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: 0x30120 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: 0x30124 65// SEC: Size: 8 66 67// SEC: Dynamic Relocations { 68// SEC-NEXT: } 69 70// CHECK: Disassembly of section .text: 71// CHECK-EMPTY: 72// CHECK-NEXT: <_start>: 73/// offset of x from Thread pointer = (TcbSize + 0x0 = 0x8) 74// CHECK-NEXT: 20114: 08 00 00 00 75/// offset of z from Thread pointer = (TcbSize + 0x8 = 0x10) 76// CHECK-NEXT: 20118: 10 00 00 00 77/// offset of y from Thread pointer = (TcbSize + 0x4 = 0xc) 78// CHECK-NEXT: 2011c: 0c 00 00 00 79