[Lldb-commits] [lldb] [lldb] Support PtrAuth in the expression evaluator (PR #186001)
Jonas Devlieghere via lldb-commits
lldb-commits at lists.llvm.org
Fri Mar 13 10:57:50 PDT 2026
================
@@ -0,0 +1,180 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "InjectPointerSigningFixups.h"
+#include "llvm/IR/Constants.h"
+#include "llvm/IR/Function.h"
+#include "llvm/IR/IRBuilder.h"
+#include "llvm/IR/Module.h"
+#include "llvm/Support/raw_ostream.h"
+#include "llvm/TargetParser/Triple.h"
+
+using namespace llvm;
+
+namespace {
+struct PtrAuthFixup {
+ GlobalVariable *GV;
+ ConstantPtrAuth *CPA;
+ SmallVector<unsigned> Indices;
+};
+} // namespace
+
+/// Recursively walk a constant looking for ConstantPtrAuth expressions.
+/// When found, record the global variable containing the ConstantPtrAuth and
+/// the index path to reach it within the initializer.
+static void findPtrAuth(Constant *C, GlobalVariable &GV,
+ SmallVector<unsigned> &Indices,
+ SmallVectorImpl<PtrAuthFixup> &Fixups) {
+ if (auto *CPA = dyn_cast<ConstantPtrAuth>(C)) {
+ Fixups.push_back({&GV, CPA, Indices});
+ return;
+ }
+ for (unsigned I = 0, E = C->getNumOperands(); I != E; ++I) {
+ if (auto *COp = dyn_cast<Constant>(C->getOperand(I))) {
+ Indices.push_back(I);
+ findPtrAuth(COp, GV, Indices, Fixups);
+ Indices.pop_back();
+ }
+ }
+}
+
+namespace lldb_private {
+
----------------
JDevlieghere wrote:
Done, let me know if you're happy with the wording and example. I also switched the name of the helper again as I think `arm64e` was a bit too opaque.
https://github.com/llvm/llvm-project/pull/186001
More information about the lldb-commits
mailing list