brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.7 KiB · b3a616f Raw
106 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 --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 global-dynamic TLS model. Dynamic Loader finds8/// module index R_ARM_TLS_DTPMOD32 and the offset within the module9/// R_ARM_TLS_DTPOFF32. One of the variables is hidden which permits relaxation10/// to local dynamic11 12 .text13 .syntax unified14 .globl  func15 .p2align        216 .type   func,%function17func:18.L0:19 nop20.L1:21 nop22.L2:23 nop24 25 .p2align        226/// Generate R_ARM_TLS_GD32 relocations27/// Allocates a pair of GOT entries dynamically relocated by R_ARM_TLS_DTPMOD3228/// and R_ARM_TLS_DTPOFF32 respectively. The literal contains the offset of the29/// first GOT entry from the place30.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 = 1035/// __thread int y;36/// __thread int z __attribute((visibility("hidden")))37 38 .hidden z39 .globl  z40 .globl  y41 .globl  x42 43 .section       .tbss,"awT",%nobits44 .p2align  245.TLSSTART:46 .type  z, %object47z:48 .space 449 .type  y, %object50y:51 .space 452 .section       .tdata,"awT",%progbits53 .p2align 254 .type  x, %object55x:56 .word  1057 58// SEC:      Name: .tdata59// SEC-NEXT: Type: SHT_PROGBITS60// SEC-NEXT: Flags [61// SEC-NEXT:   SHF_ALLOC62// SEC-NEXT:   SHF_TLS63// SEC-NEXT:   SHF_WRITE64// SEC-NEXT:  ]65// SEC-NEXT: Address: 0x2021066// SEC:      Size: 467// SEC:      Name: .tbss68// SEC-NEXT: Type: SHT_NOBITS69// SEC-NEXT: Flags [70// SEC-NEXT:   SHF_ALLOC71// SEC-NEXT:   SHF_TLS72// SEC-NEXT:   SHF_WRITE73// SEC-NEXT: ]74// SEC-NEXT: Address: 0x2021475// SEC:      Size: 876 77// SEC:      Name: .got78// SEC-NEXT: Type: SHT_PROGBITS79// SEC-NEXT: Flags [80// SEC-NEXT:   SHF_ALLOC81// SEC-NEXT:   SHF_WRITE82// SEC-NEXT: ]83// SEC-NEXT: Address: 0x2026484// SEC:      Size: 2485 86// SEC: Dynamic Relocations {87// SEC-NEXT: 0x20274 R_ARM_TLS_DTPMOD32 -88// SEC-NEXT: 0x20264 R_ARM_TLS_DTPMOD32 x89// SEC-NEXT: 0x20268 R_ARM_TLS_DTPOFF32 x90// SEC-NEXT: 0x2026C R_ARM_TLS_DTPMOD32 y91// SEC-NEXT: 0x20270 R_ARM_TLS_DTPOFF32 y92 93 94// CHECK-LABEL: 000101f8 <func>:95// CHECK-NEXT:    101f8:      e320f000        nop96// CHECK-NEXT:    101fc:      e320f000        nop97// CHECK-NEXT:    10200:      e320f000        nop98 99/// (0x20264 - 0x1204) + (0x10204 - 0x101f8 - 8) = 0x1f064100// CHECK:         10204: 64 00 01 00101/// (0x2026c - 0x10204) + (0x10204 - 0x101fc - 8) = 0x10068102// CHECK-NEXT:    10208: 68 00 01 00103/// (0x20274 - 0x10204) + (0x10204 - 0x10200 - 8) = 0x1006c104// CHECK-NEXT:    1020c: 6c 00 01 00105 106