[lld] [lld] Add thunks for hexagon (PR #111217)
Brian Cain via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 15 05:57:38 PDT 2025
================
@@ -0,0 +1,75 @@
+# REQUIRES: hexagon
+# RUN: rm -rf %t && split-file %s %t && cd %t
+# RUN: llvm-mc -filetype=obj -triple=hexagon-unknown-elf external.s -o external.o
+# RUN: ld.lld -shared external.o -soname external.so -o external.so
+# RUN: llvm-mc -filetype=obj -triple=hexagon-unknown-elf main.s -o main.o
+# RUN: ld.lld main.o external.so -o test
+# RUN: llvm-objdump -d --no-show-raw-insn test | FileCheck %s
+
+## Test thunk range scenarios for Hexagon R_HEX_PLT_B22_PCREL relocations.
+## PLT calls use the same ±8MB range as regular calls but go through PLT entries.
+## This test verifies thunk generation for PLT calls at range boundaries.
+
+#--- external.s
+.globl extern_within_range, extern_beyond_range, extern_close
+.type extern_within_range, @function
+.type extern_beyond_range, @function
+.type extern_close, @function
+
+extern_within_range:
+ jumpr r31
+
+extern_beyond_range:
+ jumpr r31
+
+extern_close:
+ jumpr r31
+
+#--- main.s
+.globl _start
+.type _start, @function
+_start:
+ ## Test PLT calls to external functions at various ranges
+ call extern_within_range at PLT
+ call extern_beyond_range at PLT
+ call extern_close at PLT
+ jumpr r31
+
+.skip 0x200000
+
+# CHECK: Disassembly of section .text:
+# CHECK: 0002021c <_start>:
+# CHECK-NEXT: { call 0x220250 }
+# CHECK-NEXT: { call 0x220260 }
+# CHECK-NEXT: { call 0x220270 }
+# CHECK-NEXT: { jumpr r31 }
+
+## Verify PLT header and entries are created with exact addresses
+# CHECK: Disassembly of section .plt:
+# CHECK: 00220230 <.plt>:
+# CHECK-NEXT: { immext(#0x20080)
+# CHECK-NEXT: r28 = add(pc,##0x200b8) }
+# CHECK-NEXT: { r14 -= add(r28,#0x10)
+# CHECK-NEXT: r15 = memw(r28+#0x8)
+# CHECK-NEXT: r28 = memw(r28+#0x4) }
+# CHECK-NEXT: { r14 = asr(r14,#0x2)
+# CHECK-NEXT: jumpr r28 }
+# CHECK-NEXT: { trap0(#0xdb) }
+
+# CHECK: 00220250 <extern_within_range at plt>:
----------------
androm3da wrote:
fixed
https://github.com/llvm/llvm-project/pull/111217
More information about the llvm-commits
mailing list