99 lines · plain
1// REQUIRES: arm2// RUN: llvm-mc %s -o %t.o -filetype=obj -triple=armv7a-linux-gnueabi3// RUN: ld.lld %t.o -o %t.so -shared4// RUN: llvm-readobj -S -d --dyn-relocations %t.so | FileCheck --check-prefix=SEC %s5// RUN: llvm-objdump -d --triple=armv7a-linux-gnueabi %t.so | FileCheck %s6 7/// Test the handling of the initial-exec TLS model. Relative location within8/// static TLS is a run-time constant computed by dynamic loader as a result9/// of the R_ARM_TLS_TPOFF32 relocation.10 11 .syntax unified12 .arm13 .globl func14 .type func,%function15 .p2align 216func:17.L0:18 nop19.L1:20 nop21.L2:22 nop23 24 .p2align 225/// Generate R_ARM_TLS_IE32 static relocations26/// Allocates a GOT entry dynamically relocated by R_ARM_TLS_TPOFF3227/// literal contains the offset of the GOT entry from the place28.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 = 1033/// __thread int y;34/// __thread int z __attribute((visibility("hidden")))35 .hidden z36 .globl z37 .globl y38 .globl x39 40 .section .tbss,"awT",%nobits41 .p2align 242.TLSSTART:43 .type z, %object44z:45 .space 446 .type y, %object47y:48 .space 449 .section .tdata,"awT",%progbits50 .p2align 251 .type x, %object52x:53 .word 1054 55// SEC: Name: .tdata56// SEC-NEXT: Type: SHT_PROGBITS57// SEC-NEXT: Flags [58// SEC-NEXT: SHF_ALLOC59// SEC-NEXT: SHF_TLS60// SEC-NEXT: SHF_WRITE61// SEC: Size: 462// SEC: Name: .tbss63// SEC-NEXT: Type: SHT_NOBITS64// SEC-NEXT: Flags [65// SEC-NEXT: SHF_ALLOC66// SEC-NEXT: SHF_TLS67// SEC-NEXT: SHF_WRITE68// SEC: Size: 869 70// SEC: Name: .got71// SEC-NEXT: Type: SHT_PROGBITS72// SEC-NEXT: Flags [73// SEC-NEXT: SHF_ALLOC74// SEC-NEXT: SHF_WRITE75// SEC-NEXT: ]76// SEC-NEXT: Address: 0x2025C77// SEC: Size: 1278 79 80// SEC: FLAGS STATIC_TLS81// SEC: Dynamic Relocations {82// SEC: 0x20264 R_ARM_TLS_TPOFF3283// SEC: 0x2025C R_ARM_TLS_TPOFF32 x84// SEC: 0x20260 R_ARM_TLS_TPOFF32 y85 86// CHECK: Disassembly of section .text:87// CHECK-EMPTY:88// CHECK-NEXT: <func>:89// CHECK-NEXT: 101e8: e320f000 nop90// CHECK-NEXT: 101ec: e320f000 nop91// CHECK-NEXT: 101f0: e320f000 nop92 93/// (0x20264 - 0x101f4) + (0x101f4 - 0x101e8 - 8) = 0x1006c94// CHECK: 101f4: 6c 00 01 0095/// (0x2025C - 0x101f8) + (0x101f8 - 0x101ec - 8) = 0x1006c96// CHECK-NEXT: 101f8: 6c 00 01 0097/// (0x20260 - 0x101f8) + (0x101f8 - 0x101f0 - 8) = 0x1006c98// CHECK-NEXT: 101fc: 6c 00 01 0099