Skip to content

Commit 987ed13

Browse files
committed
[𝘀𝗽𝗿] initial version
Created using spr 1.3.6-beta.1
2 parents e20413c + 4faebad commit 987ed13

File tree

98 files changed

+1600
-177
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+1600
-177
lines changed

clang/lib/CodeGen/CGPointerAuth.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -440,9 +440,9 @@ CodeGenModule::getConstantSignedPointer(llvm::Constant *Pointer, unsigned Key,
440440
IntegerDiscriminator = llvm::ConstantInt::get(Int64Ty, 0);
441441
}
442442

443-
return llvm::ConstantPtrAuth::get(Pointer,
444-
llvm::ConstantInt::get(Int32Ty, Key),
445-
IntegerDiscriminator, AddressDiscriminator);
443+
return llvm::ConstantPtrAuth::get(
444+
Pointer, llvm::ConstantInt::get(Int32Ty, Key), IntegerDiscriminator,
445+
AddressDiscriminator, llvm::Constant::getNullValue(UnqualPtrTy));
446446
}
447447

448448
/// Does a given PointerAuthScheme require us to sign a value

libcxx/include/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,7 @@ set(files
375375
__flat_set/flat_set.h
376376
__flat_set/ra_iterator.h
377377
__flat_set/utils.h
378+
__force_nonstandard_layout
378379
__format/buffer.h
379380
__format/concepts.h
380381
__format/container_adaptor.h

libcxx/include/__config

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,8 +484,21 @@ typedef __char32_t char32_t;
484484
# define _LIBCPP_EXCEPTIONS_SIG e
485485
# endif
486486

487+
# if !_LIBCPP_HAS_EXCEPTIONS
488+
# define _LIBCPP_EXCEPTIONS_SIG n
489+
# else
490+
# define _LIBCPP_EXCEPTIONS_SIG e
491+
# endif
492+
493+
# if __has_feature(pointer_field_protection)
494+
# define _LIBCPP_PFP_SIG p
495+
# else
496+
# define _LIBCPP_PFP_SIG
497+
# endif
498+
487499
# define _LIBCPP_ODR_SIGNATURE \
488-
_LIBCPP_CONCAT(_LIBCPP_CONCAT(_LIBCPP_HARDENING_SIG, _LIBCPP_EXCEPTIONS_SIG), _LIBCPP_VERSION)
500+
_LIBCPP_CONCAT(_LIBCPP_CONCAT(_LIBCPP_CONCAT(_LIBCPP_HARDENING_SIG, _LIBCPP_EXCEPTIONS_SIG), _LIBCPP_PFP_SIG), \
501+
_LIBCPP_VERSION)
489502

490503
// This macro marks a symbol as being hidden from libc++'s ABI. This is achieved
491504
// on two levels:
@@ -1262,6 +1275,12 @@ typedef __char32_t char32_t;
12621275
# define _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER 0
12631276
# endif
12641277

1278+
# if __has_feature(pointer_field_protection)
1279+
# define _LIBCPP_NO_PFP [[clang::no_field_protection]]
1280+
# else
1281+
# define _LIBCPP_NO_PFP
1282+
# endif
1283+
12651284
#endif // __cplusplus
12661285

12671286
#endif // _LIBCPP___CONFIG
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// -*- C++ -*-
2+
//===----------------------------------------------------------------------===//
3+
//
4+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5+
// See https://llvm.org/LICENSE.txt for license information.
6+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7+
//
8+
//===----------------------------------------------------------------------===//
9+
10+
#ifndef _LIBCPP___FORCE_NONSTANDARD_LAYOUT
11+
#define _LIBCPP___FORCE_NONSTANDARD_LAYOUT
12+
13+
#include <__config>
14+
15+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16+
# pragma GCC system_header
17+
#endif
18+
19+
_LIBCPP_BEGIN_NAMESPACE_STD
20+
21+
// Force a class to be non-standard layout by giving it two bases with the same
22+
// type. This is useful when structure protection is enabled because structure
23+
// protection cannot be applied to standard layout classes. We may use this in
24+
// cases where the standard does not specify whether a standard library class is
25+
// standard layout. See C++2a [class]p7:
26+
// A class S is a standard-layout class if it:
27+
// -- has at most one base class subobject of any given type
28+
_LIBCPP_DIAGNOSTIC_PUSH
29+
_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Winaccessible-base")
30+
class __force_nonstandard_layout_base1 {};
31+
class __force_nonstandard_layout_base2 : __force_nonstandard_layout_base1 {};
32+
class __force_nonstandard_layout : __force_nonstandard_layout_base1, __force_nonstandard_layout_base2 {};
33+
_LIBCPP_DIAGNOSTIC_POP
34+
35+
#if __has_feature(pointer_field_protection)
36+
# define _LIBCPP_MAYBE_FORCE_NONSTANDARD_LAYOUT : __force_nonstandard_layout
37+
#else
38+
# define _LIBCPP_MAYBE_FORCE_NONSTANDARD_LAYOUT
39+
#endif
40+
41+
_LIBCPP_END_NAMESPACE_STD
42+
43+
#endif // _LIBCPP___FORCE_NONSTANDARD_LAYOUT

libcxx/include/__functional/function.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <__config>
1515
#include <__cstddef/nullptr_t.h>
1616
#include <__exception/exception.h>
17+
#include <__force_nonstandard_layout>
1718
#include <__functional/binary_function.h>
1819
#include <__functional/invoke.h>
1920
#include <__functional/unary_function.h>
@@ -427,7 +428,7 @@ template <class _Fp>
427428
class __policy_func;
428429

429430
template <class _Rp, class... _ArgTypes>
430-
class __policy_func<_Rp(_ArgTypes...)> {
431+
class __policy_func<_Rp(_ArgTypes...)> _LIBCPP_MAYBE_FORCE_NONSTANDARD_LAYOUT {
431432
// Inline storage for small objects.
432433
__policy_storage __buf_;
433434

libcxx/include/__memory/shared_ptr.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <__cstddef/nullptr_t.h>
1717
#include <__cstddef/ptrdiff_t.h>
1818
#include <__exception/exception.h>
19+
#include <__force_nonstandard_layout>
1920
#include <__functional/binary_function.h>
2021
#include <__functional/operations.h>
2122
#include <__functional/reference_wrapper.h>
@@ -304,7 +305,7 @@ using __shared_ptr_nullptr_deleter_ctor_reqs _LIBCPP_NODEBUG =
304305
#endif
305306

306307
template <class _Tp>
307-
class _LIBCPP_SHARED_PTR_TRIVIAL_ABI shared_ptr {
308+
class _LIBCPP_SHARED_PTR_TRIVIAL_ABI shared_ptr _LIBCPP_MAYBE_FORCE_NONSTANDARD_LAYOUT {
308309
struct __nullptr_sfinae_tag {};
309310

310311
public:
@@ -1204,7 +1205,7 @@ inline _LIBCPP_HIDE_FROM_ABI _Dp* get_deleter(const shared_ptr<_Tp>& __p) _NOEXC
12041205
#endif // _LIBCPP_HAS_RTTI
12051206

12061207
template <class _Tp>
1207-
class _LIBCPP_SHARED_PTR_TRIVIAL_ABI weak_ptr {
1208+
class _LIBCPP_SHARED_PTR_TRIVIAL_ABI weak_ptr _LIBCPP_MAYBE_FORCE_NONSTANDARD_LAYOUT {
12081209
public:
12091210
#if _LIBCPP_STD_VER >= 17
12101211
typedef remove_extent_t<_Tp> element_type;

libcxx/include/__memory/unique_ptr.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <__config>
1818
#include <__cstddef/nullptr_t.h>
1919
#include <__cstddef/size_t.h>
20+
#include <__force_nonstandard_layout>
2021
#include <__functional/hash.h>
2122
#include <__functional/operations.h>
2223
#include <__memory/allocator_traits.h> // __pointer
@@ -127,7 +128,7 @@ struct __unique_ptr_deleter_sfinae<_Deleter&> {
127128
#endif
128129

129130
template <class _Tp, class _Dp = default_delete<_Tp> >
130-
class _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI unique_ptr {
131+
class _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI unique_ptr _LIBCPP_MAYBE_FORCE_NONSTANDARD_LAYOUT {
131132
public:
132133
typedef _Tp element_type;
133134
typedef _Dp deleter_type;
@@ -396,7 +397,7 @@ struct __unique_ptr_array_bounds_stored {
396397
};
397398

398399
template <class _Tp, class _Dp>
399-
class _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI unique_ptr<_Tp[], _Dp> {
400+
class _LIBCPP_UNIQUE_PTR_TRIVIAL_ABI unique_ptr<_Tp[], _Dp> _LIBCPP_MAYBE_FORCE_NONSTANDARD_LAYOUT {
400401
public:
401402
typedef _Tp element_type;
402403
typedef _Dp deleter_type;

libcxx/include/__tree

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <__algorithm/min.h>
1414
#include <__assert>
1515
#include <__config>
16+
#include <__force_nonstandard_layout>
1617
#include <__fwd/map.h>
1718
#include <__fwd/pair.h>
1819
#include <__fwd/set.h>
@@ -782,7 +783,7 @@ _LIBCPP_DIAGNOSE_WARNING(!__is_invocable_v<_Compare const&, _Tp const&, _Tp cons
782783
int __diagnose_non_const_comparator();
783784

784785
template <class _Tp, class _Compare, class _Allocator>
785-
class __tree {
786+
class __tree _LIBCPP_MAYBE_FORCE_NONSTANDARD_LAYOUT {
786787
public:
787788
using value_type = __get_node_value_type_t<_Tp>;
788789
typedef _Compare value_compare;

libcxx/include/__type_traits/is_trivially_relocatable.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,13 @@ template <class _Tp, class = void>
3434
struct __libcpp_is_trivially_relocatable : is_trivially_copyable<_Tp> {};
3535
#endif
3636

37+
// __trivially_relocatable on libc++'s builtin types does not currently return the right answer with PFP.
38+
#if !__has_feature(pointer_field_protection)
3739
template <class _Tp>
3840
struct __libcpp_is_trivially_relocatable<_Tp,
3941
__enable_if_t<is_same<_Tp, typename _Tp::__trivially_relocatable>::value> >
4042
: true_type {};
43+
#endif
4144

4245
_LIBCPP_END_NAMESPACE_STD
4346

libcxx/include/__vector/vector.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <__assert>
2222
#include <__config>
2323
#include <__debug_utils/sanitizers.h>
24+
#include <__force_nonstandard_layout>
2425
#include <__format/enable_insertable.h>
2526
#include <__fwd/vector.h>
2627
#include <__iterator/advance.h>
@@ -85,7 +86,7 @@ _LIBCPP_PUSH_MACROS
8586
_LIBCPP_BEGIN_NAMESPACE_STD
8687

8788
template <class _Tp, class _Allocator /* = allocator<_Tp> */>
88-
class vector {
89+
class vector _LIBCPP_MAYBE_FORCE_NONSTANDARD_LAYOUT {
8990
public:
9091
//
9192
// Types

0 commit comments

Comments
 (0)