[lld] [LLD][ELF][AArch64] Add BTI Aware long branch thunks (PR #108989)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sat Sep 21 18:05:44 PDT 2024


================
@@ -28,6 +28,38 @@ uint64_t elf::getAArch64Page(uint64_t expr) {
   return expr & ~static_cast<uint64_t>(0xFFF);
 }
 
+// A BTI landing pad is a valid target for an indirect branch
+// when the Branch Target Identification has been enabled.
+// As linker generated branches are via x16 the
+// BTI landing pads are defined as:
+// BTI C, BTI J, BTI JC, PACIASP, PACIBSP.
+bool elf::isAArch64BTILandingPad(Symbol &s, int64_t a) {
+  // PLT entries accessed indirectly have a BTI c.
+  if (s.isInPlt())
+    return true;
+  Defined *d = dyn_cast_or_null<Defined>(&s);
----------------
MaskRay wrote:

`dyn_cast` since `&s` cannot be nullptr.

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


More information about the llvm-commits mailing list