[llvm-branch-commits] [clang] [llvm] [clang] Implement function pointer signing and authenticated function calls (PR #93906)
Akira Hatanaka via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Jun 18 21:55:52 PDT 2024
================
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 %s -triple arm64e-apple-ios13 -fptrauth-calls -fptrauth-intrinsics -disable-llvm-passes -emit-llvm -o- | FileCheck %s
+// RUN: %clang_cc1 -xc++ %s -triple arm64e-apple-ios13 -fptrauth-calls -fptrauth-intrinsics -disable-llvm-passes -emit-llvm -o- | FileCheck %s --check-prefixes=CHECK,CXX
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void f(void);
+
+#ifdef __cplusplus
+
+// CXX-LABEL: define internal void @__cxx_global_var_init()
+// CXX: store ptr getelementptr inbounds (i32, ptr ptrauth (ptr @f, i32 0), i64 2), ptr @_ZL2fp, align 8
+
+__attribute__((used))
+void (*const fp)(void) = (void (*)(void))((int *)&f + 2); // Error in C mode.
----------------
ahatanak wrote:
In C++, the global constructor can initialize the variable.
https://github.com/llvm/llvm-project/pull/93906
More information about the llvm-branch-commits
mailing list