diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt index a119850cd808e..3a87029b52980 100644 --- a/libcxx/CMakeLists.txt +++ b/libcxx/CMakeLists.txt @@ -201,7 +201,11 @@ set(LIBCXX_LIBRARY_VERSION "${LIBCXX_ABI_VERSION}.0" CACHE STRING For example, -DLIBCXX_LIBRARY_VERSION=x.y will result in the library being named libc++.x.y.dylib, along with the usual symlinks pointing to that. On Apple platforms, this also controls the linker's 'current_version' property.") -set(LIBCXX_ABI_NAMESPACE "__${LIBCXX_ABI_VERSION}" CACHE STRING "The inline ABI namespace used by libc++. It defaults to __n where `n` is the current ABI version.") +set(default_abi_namespace "__${LIBCXX_ABI_VERSION}") +if(NOT LIBCXX_PFP STREQUAL "none") + set(default_abi_namespace "${default_abi_namespace}_pfp_${LIBCXX_PFP}") +endif() +set(LIBCXX_ABI_NAMESPACE "${default_abi_namespace}" CACHE STRING "The inline ABI namespace used by libc++. It defaults to __n where `n` is the current ABI version.") if (NOT LIBCXX_ABI_NAMESPACE MATCHES "__.*") message(FATAL_ERROR "LIBCXX_ABI_NAMESPACE must be a reserved identifier, got '${LIBCXX_ABI_NAMESPACE}'.") endif() diff --git a/libcxx/include/__config b/libcxx/include/__config index b4c081dcdff1b..7e996bbf92ba0 100644 --- a/libcxx/include/__config +++ b/libcxx/include/__config @@ -1263,6 +1263,12 @@ typedef __char32_t char32_t; # define _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER 0 # endif +# if __has_cpp_attribute(_Clang::__no_field_protection__) +# define _LIBCPP_NO_PFP [[_Clang::__no_field_protection__]] +# else +# define _LIBCPP_NO_PFP +# endif + #endif // __cplusplus #endif // _LIBCPP___CONFIG diff --git a/libcxx/include/__type_traits/is_trivially_relocatable.h b/libcxx/include/__type_traits/is_trivially_relocatable.h index 9b0e240de55f4..cf3cfd67fbf31 100644 --- a/libcxx/include/__type_traits/is_trivially_relocatable.h +++ b/libcxx/include/__type_traits/is_trivially_relocatable.h @@ -34,10 +34,13 @@ template struct __libcpp_is_trivially_relocatable : is_trivially_copyable<_Tp> {}; #endif +// __trivially_relocatable on libc++'s builtin types does not currently return the right answer with PFP. +#if !defined(__POINTER_FIELD_PROTECTION__) template struct __libcpp_is_trivially_relocatable<_Tp, __enable_if_t::value> > : true_type {}; +#endif _LIBCPP_END_NAMESPACE_STD diff --git a/libcxx/include/typeinfo b/libcxx/include/typeinfo index 24aaabf0a87df..a1ee4155bcb3d 100644 --- a/libcxx/include/typeinfo +++ b/libcxx/include/typeinfo @@ -300,7 +300,7 @@ class _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_TYPE_INFO_VTABLE_POINTER_AUTH type_info protected: typedef __type_info_implementations::__impl __impl; - __impl::__type_name_t __type_name; + _LIBCPP_NO_PFP __impl::__type_name_t __type_name; _LIBCPP_HIDE_FROM_ABI explicit type_info(const char* __n) : __type_name(__impl::__string_to_type_name(__n)) {} diff --git a/libcxxabi/include/__cxxabi_config.h b/libcxxabi/include/__cxxabi_config.h index 759445dac91f9..c8c3b18d545d1 100644 --- a/libcxxabi/include/__cxxabi_config.h +++ b/libcxxabi/include/__cxxabi_config.h @@ -109,4 +109,10 @@ # define _LIBCXXABI_NOEXCEPT noexcept #endif +#if defined(__POINTER_FIELD_PROTECTION__) +# define _LIBCXXABI_NO_PFP [[_Clang::__no_field_protection__]] +#else +# define _LIBCXXABI_NO_PFP +#endif + #endif // ____CXXABI_CONFIG_H diff --git a/libcxxabi/src/private_typeinfo.h b/libcxxabi/src/private_typeinfo.h index 328a02edef5c1..a3bc0bffd41bc 100644 --- a/libcxxabi/src/private_typeinfo.h +++ b/libcxxabi/src/private_typeinfo.h @@ -145,7 +145,7 @@ class _LIBCXXABI_TYPE_VIS __class_type_info : public __shim_type_info { // Has one non-virtual public base class at offset zero class _LIBCXXABI_TYPE_VIS __si_class_type_info : public __class_type_info { public: - const __class_type_info *__base_type; + _LIBCXXABI_NO_PFP const __class_type_info *__base_type; _LIBCXXABI_HIDDEN virtual ~__si_class_type_info(); @@ -204,7 +204,7 @@ class _LIBCXXABI_TYPE_VIS __vmi_class_type_info : public __class_type_info { class _LIBCXXABI_TYPE_VIS __pbase_type_info : public __shim_type_info { public: unsigned int __flags; - const __shim_type_info *__pointee; + _LIBCXXABI_NO_PFP const __shim_type_info *__pointee; enum __masks { __const_mask = 0x1, @@ -245,7 +245,7 @@ class _LIBCXXABI_TYPE_VIS __pointer_type_info : public __pbase_type_info { class _LIBCXXABI_TYPE_VIS __pointer_to_member_type_info : public __pbase_type_info { public: - const __class_type_info *__context; + _LIBCXXABI_NO_PFP const __class_type_info *__context; _LIBCXXABI_HIDDEN virtual ~__pointer_to_member_type_info(); _LIBCXXABI_HIDDEN virtual bool can_catch(const __shim_type_info *,