[llvm-branch-commits] Add pointer field protection feature. (PR #133538)

Oliver Hunt via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed May 14 23:47:35 PDT 2025


================
@@ -7538,6 +7538,14 @@ static bool IsEligibleForTrivialRelocation(Sema &SemaRef,
     if (!SemaRef.IsCXXTriviallyRelocatableType(Field->getType()))
       return false;
   }
+
+  // FIXME: PFP should not affect trivial relocatability, instead it should
+  // affect the implementation of std::trivially_relocate. See:
+  // https://discourse.llvm.org/t/rfc-structure-protection-a-family-of-uaf-mitigation-techniques/85555/16?u=pcc
+  if (!SemaRef.Context.arePFPFieldsTriviallyRelocatable(D) &&
----------------
ojhunt wrote:

I think it would be reasonable to make a general `ASTContext::HasAddressDiscriminatedData(...)` ( or similar method that can check for pointer auth and PFP, and an associated update of the existing `hasAddressDiscriminatedPointerAuth` calls to use that function for semantic checks related to "does this contain values with storage derived representation" at least. Don't quote me on the naming though, because I am terrible at that.

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


More information about the llvm-branch-commits mailing list