52 lines · plain
1 2# REQUIRES: hexagon3# RUN: llvm-mc -filetype=obj -triple=hexagon-unknown-elf %s -o %t.o4# RUN: ld.lld -shared %t.o -o %t.so5# RUN: llvm-readobj -r %t.so | FileCheck --check-prefix=RELOC %s6# RUN: llvm-readobj -r %t.o | FileCheck --check-prefix=REL %s7# RUN: llvm-objdump -d --no-show-raw-insn --print-imm-hex %t.so | FileCheck %s8 9## Prior to D77021 lld would error "relocation R_HEX_GD_PLT_B22_PCREL cannot refer to absolute symbol".10## A PC-relative relocation referencing a non-preemptible absolute symbol (due to STT_TLS) is not representable in -pie/-shared mode.11## For this case we will actually patch the symbol to the external __tls_get_addr which is preemptible.12 13.globl _start14.type _start, @function15 16# RELOC: Section ({{.*}}) .rela.plt {17# RELOC-NEXT: R_HEX_JMP_SLOT - 0x018# RELOC-NEXT: R_HEX_JMP_SLOT __tls_get_addr 0x019# RELOC-NEXT: }20 21# REL: R_HEX_B32_PCREL_X _GLOBAL_OFFSET_TABLE_ 0x022# REL-NEXT: R_HEX_6_PCREL_X _GLOBAL_OFFSET_TABLE_ 0x423# REL-NEXT: R_HEX_GD_GOT_32_6_X a 0x024# REL-NEXT: R_HEX_GD_GOT_16_X a 0x025# REL-NEXT: R_HEX_GD_PLT_B22_PCREL a 0x026# REL-NEXT: R_HEX_GD_PLT_B32_PCREL_X a 0x027# REL-NEXT: R_HEX_GD_PLT_B22_PCREL_X a 0x428 29# CHECK: { immext(#{{.*}})30# CHECK-NEXT: r2 = add(pc,##{{.*}}) }31# CHECK-NEXT: { immext(#{{.*}})32# CHECK-NEXT: r0 = add(r2,##-{{.*}}) }33# CHECK-NEXT: { call {{.*}} }34# CHECK-NEXT: { immext({{.*}})35# CHECK-NEXT: call {{.*}} }36# CHECK-NEXT: { r0 = memw(r0+#0x0) }37 38_start:39 r2 = add(pc,##_GLOBAL_OFFSET_TABLE_@PCREL)40 r0 = add(r2,##a@GDGOT)41 call a@GDPLT42 call ##a@GDPLT43 r0 = memw(r0+#0)44 45## a is non-preemptible due to STV_HIDDEN visibility.46## We can achieve the same effect with -Bsymbolic.47.section .tdata,"awT",@progbits48.globl a49.hidden a50a:51.word 152