45 lines · c
1// Test checks that BOLT can process binaries with TLS relocations2 3__thread struct str {4 int a;5 int b;6} tbssstruct = {}, tdatastruct = {4, 2};7 8extern __thread struct str extstruct;9 10extern void processAddr(volatile void *);11 12int main() {13 // R_AARCH64_TLSDESC_ADR_PAGE21 and R_AARCH64_TLSDESC_LD64_LO12_NC are14 // produced for pie binaries in all cases below.15 16 // The R_TLSLE_ADD_TPREL_HI12 and R_TLSLE_ADD_TPREL_LO12_NC for17 // relocations in .tbss and .tdata18 processAddr(&tbssstruct.b);19 processAddr(&tdatastruct.b);20 21 // The R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21 and22 // R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC relocations23 processAddr(&extstruct.b);24}25 26// REQUIRES: system-linux27// RUN: %clang %cflags -no-pie %s -o %t.exe -Wl,-q \28// RUN: -Wl,--unresolved-symbols=ignore-all \29// RUN: -fuse-ld=lld \30// RUN: -nostdlib31// RUN: llvm-bolt %t.exe -o %t.bolt32// RUN: %clang %cflags -fPIC -pie %s -o %t_pie.exe -Wl,-q \33// RUN: -Wl,--unresolved-symbols=ignore-all \34// RUN: -target aarch64-linux -fuse-ld=lld \35// RUN: -nostdlib36// RUN: llvm-bolt %t_pie.exe -o %t.bolt37 38// RUN: %clang %cflags -fPIC -shared %s -o %t.so -Wl,-q -fuse-ld=lld39// RUN: llvm-objdump -d -r --disassemble-symbols=main %t.so | FileCheck %s40// RUN: llvm-bolt %t.so -o %t.bolt.so41 42// Verify that unoptimized TLS access was generated for shared object.43// CHECK: adrp x044// CHECK-NEXT: R_AARCH64_TLSDESC_ADR_PAGE21 tbssstruct45