[llvm-branch-commits] Add pointer field protection feature. (PR #133538)
Peter Collingbourne via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed May 14 22:25:30 PDT 2025
================
@@ -2201,6 +2215,22 @@ void CodeGenFunction::EmitCXXConstructorCall(
EmitTypeCheck(CodeGenFunction::TCK_ConstructorCall, Loc, This,
getContext().getRecordType(ClassDecl), CharUnits::Zero());
+ // When initializing an object that has pointer field protection and whose
+ // fields are not trivially relocatable we must initialize any pointer fields
+ // to a valid signed pointer (any pointer value will do, but we just use null
+ // pointers). This is because if the object is subsequently copied, its copy
+ // constructor will need to read and authenticate any pointer fields in order
+ // to copy the object to a new address, which will fail if the pointers are
+ // uninitialized.
+ if (!getContext().arePFPFieldsTriviallyRelocatable(D->getParent())) {
----------------
pcc wrote:
That's fair. This code was added while testing in our internal codebase at a time when we had a more expansive view of which fields would be subject to PFP. I will re-evaluate whether this is still needed.
https://github.com/llvm/llvm-project/pull/133538
More information about the llvm-branch-commits
mailing list