[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


================
@@ -2513,6 +2513,12 @@ def CountedByOrNull : DeclOrTypeAttr {
   let LangOpts = [COnly];
 }
 
+def NoPointerFieldProtection : DeclOrTypeAttr {
----------------
pcc wrote:

There are numerous circumstances where the C++ ABI is distinct from the platform ABI and is allowed to change. For example, most Chromium-based web browsers ship with a statically linked libc++, and the same is true for many Android apps and server-side software at Google. In the intended usage model, all of libc++ would be built with a `-fexperimental-pointer-field-protection=` flag consistent with the rest of the program.

The libc++abi opt-outs that I added are only for opting out pointer fields of RTTI structs that are generated by the compiler. In principle, we could teach the compiler to sign those pointer fields which would let us remove the opt-outs, but there is a lower ROI for subjecting those fields to PFP because the RTTI structs are not typically dynamically allocated.

We may consider adding an attribute to allow opting in in the case where the flag is not passed. But I think we should do that in a followup. We would need to carefully consider how that would interact with the other aspects of the opt-in solution, such as the pointer qualifiers.

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


More information about the llvm-branch-commits mailing list