1 2# REQUIRES: hexagon 3# RUN: llvm-mc -filetype=obj -triple=hexagon-unknown-elf %s -o %t.o 4# RUN: ld.lld -shared %t.o -o %t.so 5# RUN: llvm-readobj -r %t.so | FileCheck --check-prefix=RELOC %s 6# RUN: llvm-readobj -r %t.o | FileCheck --check-prefix=REL %s 7# RUN: llvm-objdump -d --no-show-raw-insn --print-imm-hex %t.so | FileCheck %s 8 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 _start 14.type _start, @function 15 16# RELOC: Section ({{.*}}) .rela.plt { 17# RELOC-NEXT: R_HEX_JMP_SLOT - 0x0 18# RELOC-NEXT: R_HEX_JMP_SLOT __tls_get_addr 0x0 19# RELOC-NEXT: } 20 21# REL: R_HEX_B32_PCREL_X _GLOBAL_OFFSET_TABLE_ 0x0 22# REL-NEXT: R_HEX_6_PCREL_X _GLOBAL_OFFSET_TABLE_ 0x4 23# REL-NEXT: R_HEX_GD_GOT_32_6_X a 0x0 24# REL-NEXT: R_HEX_GD_GOT_16_X a 0x0 25# REL-NEXT: R_HEX_GD_PLT_B22_PCREL a 0x0 26# REL-NEXT: R_HEX_GD_PLT_B32_PCREL_X a 0x0 27# REL-NEXT: R_HEX_GD_PLT_B22_PCREL_X a 0x4 28 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@GDPLT 42 call ##a@GDPLT 43 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",@progbits 48.globl a 49.hidden a 50a: 51.word 1 52