[lld] [LLD][AArch64] Add test for missing AArch64 BTI thunk (PR #116665)

Peter Smith via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 19 02:07:31 PST 2024


================
@@ -0,0 +1,112 @@
+// REQUIRES: aarch64
+// RUN: rm -rf %t && split-file %s %t && cd %t
+// RUN: llvm-mc -filetype=obj -triple=aarch64 asm -o a.o
+// RUN: ld.lld --script=lds a.o -o out.exe
+// RUN: llvm-objdump -d --no-show-raw-insn out.exe | FileCheck %s
+
+/// Test that a thunk that at creation time does not need to use a BTI
+/// compatible landing pad, but due to other thunk insertion ends up
+/// out of short-branch range so a BTI thunk is required after all.
+
+//--- asm
+.section ".note.gnu.property", "a"
+.p2align 3
+.long 4
+.long 0x10
+.long 0x5
+.asciz "GNU"
+
+/// Enable BTI.
+.long 0xc0000000 // GNU_PROPERTY_AARCH64_FEATURE_1_AND.
+.long 4
+.long 1          // GNU_PROPERTY_AARCH64_FEATURE_1_BTI.
+.long 0
+
+.section .text.0, "ax", %progbits
+.balign 0x1000
+.global _start
+.type _start, %function
+_start:
+/// Call that requires a thunk.
+ bl fn1
+/// padding so that we require thunks that can be placed after this section.
----------------
smithp35 wrote:

I've updated the comment to explain as best I could.

https://github.com/llvm/llvm-project/pull/116665


More information about the llvm-commits mailing list