Skip to content
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion libcxx/include/__config
Original file line number Diff line number Diff line change
Expand Up @@ -484,8 +484,21 @@ typedef __char32_t char32_t;
# define _LIBCPP_EXCEPTIONS_SIG e
# endif

# if !_LIBCPP_HAS_EXCEPTIONS
# define _LIBCPP_EXCEPTIONS_SIG n
# else
# define _LIBCPP_EXCEPTIONS_SIG e
# endif

# if defined(__POINTER_FIELD_PROTECTION__)
# define _LIBCPP_PFP_SIG p
# else
# define _LIBCPP_PFP_SIG
# endif
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is that pfp changes the layout of certain types? Why should there be an ABI tag for it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the in-memory pointer format changes so it's effectively a layout (ABI) change. Therefore we need an ABI tag change to detect/prevent linking against mismatching ABIs. This was requested by @mordante in #133538.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's only for ceses where we want different TUs to link together. Since PFP changes the layout of types that's not something we want users to do, which in turn means that we don't want to make it visible in the ABI tag. We should instead change the whole inline namespace.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I removed this logic and added CMake logic to modify the namespace name if PFP is enabled.


# define _LIBCPP_ODR_SIGNATURE \
_LIBCPP_CONCAT(_LIBCPP_CONCAT(_LIBCPP_HARDENING_SIG, _LIBCPP_EXCEPTIONS_SIG), _LIBCPP_VERSION)
_LIBCPP_CONCAT(_LIBCPP_CONCAT(_LIBCPP_CONCAT(_LIBCPP_HARDENING_SIG, _LIBCPP_EXCEPTIONS_SIG), _LIBCPP_PFP_SIG), \
_LIBCPP_VERSION)

// This macro marks a symbol as being hidden from libc++'s ABI. This is achieved
// on two levels:
Expand Down Expand Up @@ -1263,6 +1276,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
3 changes: 3 additions & 0 deletions libcxx/include/__type_traits/is_trivially_relocatable.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,13 @@ template <class _Tp, class = void>
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 <class _Tp>
struct __libcpp_is_trivially_relocatable<_Tp,
__enable_if_t<is_same<_Tp, typename _Tp::__trivially_relocatable>::value> >
: true_type {};
#endif

_LIBCPP_END_NAMESPACE_STD

Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/typeinfo
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {}

Expand Down
6 changes: 6 additions & 0 deletions libcxxabi/include/__cxxabi_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions libcxxabi/src/private_typeinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 *,
Expand Down
Loading