2018-09-28 22:09:16 +08:00
|
|
|
# REQUIRES: hexagon
|
2019-10-08 22:23:49 +08:00
|
|
|
# RUN: llvm-mc -mno-fixup -filetype=obj -triple=hexagon-unknown-elf %s -o %t.o
|
2018-09-28 22:09:16 +08:00
|
|
|
# RUN: llvm-mc -filetype=obj -triple=hexagon-unknown-elf %S/Inputs/hexagon-shared.s -o %t2.o
|
2019-09-17 10:45:38 +08:00
|
|
|
# RUN: ld.lld -shared %t2.o -soname so -o %t3.so
|
2019-10-08 22:23:49 +08:00
|
|
|
# RUN: ld.lld -shared %t.o %t3.so -o %t4.so
|
|
|
|
# RUN: ld.lld -Bsymbolic -shared %t.o %t3.so -o %t5.so
|
2018-10-04 22:54:17 +08:00
|
|
|
# RUN: llvm-objdump -d -j .plt %t4.so | FileCheck --check-prefix=PLT %s
|
|
|
|
# RUN: llvm-objdump -d -j .text %t4.so | FileCheck --check-prefix=TEXT %s
|
|
|
|
# RUN: llvm-objdump -D -j .got %t4.so | FileCheck --check-prefix=GOT %s
|
2019-08-16 23:35:02 +08:00
|
|
|
# RUN: llvm-readelf -r %t4.so | FileCheck --check-prefix=RELO %s
|
2019-10-08 22:23:49 +08:00
|
|
|
# RUN: llvm-readelf -r %t5.so | FileCheck --check-prefix=SYMBOLIC %s
|
2018-09-28 22:09:16 +08:00
|
|
|
|
2019-10-08 22:23:49 +08:00
|
|
|
.global _start, foo, hidden_symbol
|
|
|
|
.hidden hidden_symbol
|
|
|
|
_start:
|
|
|
|
# When -Bsymbolic is specified calls to locally resolvables should
|
|
|
|
# not generate a plt.
|
|
|
|
call ##foo
|
|
|
|
# Calls to hidden_symbols should not trigger a plt.
|
|
|
|
call ##hidden_symbol
|
2018-10-04 22:54:17 +08:00
|
|
|
|
2018-10-02 02:27:26 +08:00
|
|
|
# _HEX_32_PCREL
|
|
|
|
.word _DYNAMIC - .
|
2018-09-28 22:09:16 +08:00
|
|
|
call ##bar
|
2018-10-04 22:54:17 +08:00
|
|
|
|
2018-10-02 02:27:26 +08:00
|
|
|
# R_HEX_PLT_B22_PCREL
|
|
|
|
call bar@PLT
|
2019-10-08 22:23:49 +08:00
|
|
|
# R_HEX_B15_PCREL_X
|
|
|
|
if (p0) jump bar
|
|
|
|
# R_HEX_B9_PCREL_X
|
|
|
|
{ r0 = #0; jump bar }
|
2018-09-28 22:09:16 +08:00
|
|
|
|
2018-10-04 22:54:17 +08:00
|
|
|
# R_HEX_GOT_11_X and R_HEX_GOT_32_6_X
|
|
|
|
r2=add(pc,##_GLOBAL_OFFSET_TABLE_@PCREL)
|
|
|
|
r0 = memw (r2+##bar@GOT)
|
|
|
|
jumpr r0
|
|
|
|
|
2018-10-08 23:32:46 +08:00
|
|
|
# R_HEX_GOT_16_X
|
|
|
|
r0 = add(r1,##bar@GOT)
|
|
|
|
|
2020-04-11 05:19:30 +08:00
|
|
|
# R_HEX_GOT_16_X, duplex
|
|
|
|
{ r0 = add(r0,##bar@GOT)
|
|
|
|
memw(r0) = r2 }
|
|
|
|
|
|
|
|
|
2019-10-08 22:23:49 +08:00
|
|
|
# foo is local so no plt will be generated
|
|
|
|
foo:
|
|
|
|
jumpr lr
|
|
|
|
|
|
|
|
hidden_symbol:
|
|
|
|
jumpr lr
|
|
|
|
|
2019-08-16 23:35:02 +08:00
|
|
|
# R_HEX_32
|
|
|
|
.data
|
|
|
|
.global var
|
|
|
|
.type var,@object
|
|
|
|
.p2align 2
|
|
|
|
var:
|
|
|
|
.word 10
|
|
|
|
.size var, 4
|
|
|
|
.global pvar
|
|
|
|
.type pvar,@object
|
|
|
|
pvar:
|
|
|
|
.word var
|
|
|
|
.size pvar, 4
|
|
|
|
|
2018-10-02 02:27:26 +08:00
|
|
|
|
2019-10-08 22:23:49 +08:00
|
|
|
# PLT: { immext(#131264
|
|
|
|
# PLT-NEXT: r28 = add(pc,##131268) }
|
|
|
|
# PLT-NEXT: { r14 -= add(r28,#16)
|
|
|
|
# PLT-NEXT: r15 = memw(r28+#8)
|
|
|
|
# PLT-NEXT: r28 = memw(r28+#4) }
|
|
|
|
# PLT-NEXT: { r14 = asr(r14,#2)
|
|
|
|
# PLT-NEXT: jumpr r28 }
|
|
|
|
# PLT-NEXT: { trap0(#219) }
|
|
|
|
# PLT-NEXT: immext(#131200)
|
|
|
|
# PLT-NEXT: r14 = add(pc,##131252) }
|
|
|
|
# PLT-NEXT: r28 = memw(r14+#0) }
|
|
|
|
# PLT-NEXT: jumpr r28 }
|
|
|
|
|
|
|
|
# TEXT: 8c 00 01 00 0001008c
|
|
|
|
# TEXT: { call 0x102d0 }
|
|
|
|
# TEXT: if (p0) jump:nt 0x102d0
|
|
|
|
# TEXT: r0 = #0 ; jump 0x102d0
|
|
|
|
# TEXT: r0 = add(r1,##-65548)
|
2020-04-11 05:19:30 +08:00
|
|
|
# TEXT: r0 = add(r0,##-65548); memw(r0+#0) = r2 }
|
2018-10-04 22:54:17 +08:00
|
|
|
|
|
|
|
# GOT: .got:
|
2019-10-08 22:23:49 +08:00
|
|
|
# GOT: 00 00 00 00 00000000 <unknown>
|
|
|
|
|
|
|
|
# RELO: R_HEX_GLOB_DAT
|
|
|
|
# RELO: R_HEX_32
|
|
|
|
# RELO: Relocation section '.rela.plt' at offset 0x22c contains 2 entries:
|
|
|
|
# RELO: R_HEX_JMP_SLOT {{.*}} foo
|
|
|
|
# RELO-NEXT: R_HEX_JMP_SLOT {{.*}} bar
|
|
|
|
# RELO-NOT: R_HEX_JMP_SLOT {{.*}} hidden
|
2019-08-16 23:35:02 +08:00
|
|
|
|
2019-10-08 22:23:49 +08:00
|
|
|
# Make sure that no PLT is generated for a local call.
|
|
|
|
# SYMBOLIC: Relocation section '.rela.plt' at offset 0x22c contains 1 entries:
|
|
|
|
# SYMBOLIC: R_HEX_JMP_SLOT {{.*}} bar
|
|
|
|
# SYMBOLIC-NOT: R_HEX_JMP_SLOT {{.*}} foo
|