libcxxabi: Update to LLVM 19.

This commit is contained in:
Alex Rønne Petersen 2024-08-23 02:31:37 +02:00 committed by Andrew Kelley
parent 70a1805e46
commit d13bc04cb4
11 changed files with 84 additions and 55 deletions

View File

@ -48,13 +48,17 @@ extern _LIBCXXABI_FUNC_VIS void
__cxa_free_exception(void *thrown_exception) throw(); __cxa_free_exception(void *thrown_exception) throw();
// This function is an LLVM extension, which mirrors the same extension in libsupc++ and libcxxrt // This function is an LLVM extension, which mirrors the same extension in libsupc++ and libcxxrt
extern _LIBCXXABI_FUNC_VIS __cxa_exception* extern _LIBCXXABI_FUNC_VIS __cxa_exception*
#ifdef __wasm__
// In Wasm, a destructor returns its argument
__cxa_init_primary_exception(void* object, std::type_info* tinfo, void*(_LIBCXXABI_DTOR_FUNC* dest)(void*)) throw();
#else
__cxa_init_primary_exception(void* object, std::type_info* tinfo, void(_LIBCXXABI_DTOR_FUNC* dest)(void*)) throw(); __cxa_init_primary_exception(void* object, std::type_info* tinfo, void(_LIBCXXABI_DTOR_FUNC* dest)(void*)) throw();
#endif
// 2.4.3 Throwing the Exception Object // 2.4.3 Throwing the Exception Object
extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void
__cxa_throw(void *thrown_exception, std::type_info *tinfo, __cxa_throw(void *thrown_exception, std::type_info *tinfo,
#ifdef __USING_WASM_EXCEPTIONS__ #ifdef __wasm__
// In Wasm, a destructor returns its argument
void *(_LIBCXXABI_DTOR_FUNC *dest)(void *)); void *(_LIBCXXABI_DTOR_FUNC *dest)(void *));
#else #else
void (_LIBCXXABI_DTOR_FUNC *dest)(void *)); void (_LIBCXXABI_DTOR_FUNC *dest)(void *));
@ -73,6 +77,11 @@ extern _LIBCXXABI_FUNC_VIS void __cxa_end_cleanup();
#endif #endif
extern _LIBCXXABI_FUNC_VIS std::type_info *__cxa_current_exception_type(); extern _LIBCXXABI_FUNC_VIS std::type_info *__cxa_current_exception_type();
// GNU extension
// Calls `terminate` with the current exception being caught. This function is used by GCC when a `noexcept` function
// throws an exception inside a try/catch block and doesn't catch it.
extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_call_terminate(void*) throw();
// 2.5.4 Rethrowing Exceptions // 2.5.4 Rethrowing Exceptions
extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_rethrow(); extern _LIBCXXABI_FUNC_VIS _LIBCXXABI_NORETURN void __cxa_rethrow();

View File

@ -102,8 +102,6 @@ static bool state_tab_dbg() {
namespace __state_table_eh { namespace __state_table_eh {
using destruct_f = void (*)(void*);
// Definition of flags for the state table entry field 'action flag'. // Definition of flags for the state table entry field 'action flag'.
enum FSMEntryCount : intptr_t { beginCatch = -1, endCatch = -2, deleteObject = -3, cleanupLabel = -4, terminate = -5 }; enum FSMEntryCount : intptr_t { beginCatch = -1, endCatch = -2, deleteObject = -3, cleanupLabel = -4, terminate = -5 };
@ -145,8 +143,10 @@ struct FSMEntry {
intptr_t nextStatePtr; intptr_t nextStatePtr;
}; };
union { union {
// Address of the destructor function. // Address of the destructor function with 1 argument.
void (*destructor)(void*, size_t); void (*destructor)(void*);
// Address of the destructor function with 2 arguments.
void (*xlCDestructor)(void*, size_t);
// The address of the catch block or cleanup code. // The address of the catch block or cleanup code.
void* landingPad; void* landingPad;
}; };
@ -191,12 +191,12 @@ static void invoke_destructor(FSMEntry* fsmEntry, void* addr) {
try { try {
if (fsmEntry->elementCount == 1) { if (fsmEntry->elementCount == 1) {
_LIBCXXABI_TRACE_STATETAB0("calling scalar destructor\n"); _LIBCXXABI_TRACE_STATETAB0("calling scalar destructor\n");
(*fsmEntry->destructor)(addr, dtorArgument); (*fsmEntry->xlCDestructor)(addr, dtorArgument);
_LIBCXXABI_TRACE_STATETAB0("returned from scalar destructor\n"); _LIBCXXABI_TRACE_STATETAB0("returned from scalar destructor\n");
} else { } else {
_LIBCXXABI_TRACE_STATETAB0("calling vector destructor\n"); _LIBCXXABI_TRACE_STATETAB0("calling vector destructor\n");
__cxa_vec_cleanup(addr, reinterpret_cast<size_t>(fsmEntry->elementCount), fsmEntry->elemSize, __cxa_vec_cleanup(addr, reinterpret_cast<size_t>(fsmEntry->elementCount), fsmEntry->elemSize,
reinterpret_cast<destruct_f>(fsmEntry->destructor)); fsmEntry->destructor);
_LIBCXXABI_TRACE_STATETAB0("returned from vector destructor\n"); _LIBCXXABI_TRACE_STATETAB0("returned from vector destructor\n");
} }
} catch (...) { } catch (...) {
@ -213,7 +213,7 @@ static void invoke_delete(FSMEntry* fsmEntry, void* addr) {
try { try {
_LIBCXXABI_TRACE_STATETAB0("..calling delete()\n"); _LIBCXXABI_TRACE_STATETAB0("..calling delete()\n");
// 'destructor' holds a function pointer to delete(). // 'destructor' holds a function pointer to delete().
(*fsmEntry->destructor)(objectAddress, fsmEntry->elemSize); (*fsmEntry->xlCDestructor)(objectAddress, fsmEntry->elemSize);
_LIBCXXABI_TRACE_STATETAB0("..returned from delete()\n"); _LIBCXXABI_TRACE_STATETAB0("..returned from delete()\n");
} catch (...) { } catch (...) {
_LIBCXXABI_TRACE_STATETAB0("Uncaught exception in delete(), terminating\n"); _LIBCXXABI_TRACE_STATETAB0("Uncaught exception in delete(), terminating\n");
@ -681,7 +681,7 @@ static uintptr_t* skip_non_cxx_eh_aware_frames(uint32_t* Pc, uintptr_t* Sp) {
// xlclang++ compiled code. If __xlc_exception_handle() is called by // xlclang++ compiled code. If __xlc_exception_handle() is called by
// non-C++ EH aware functions, their frames are skipped until a C++ EH aware // non-C++ EH aware functions, their frames are skipped until a C++ EH aware
// frame is found. // frame is found.
// Note: make sure __xlc_excpetion_handle() is a non-leaf function. Currently // Note: make sure __xlc_exception_handle() is a non-leaf function. Currently
// it calls skip_non_cxx_eh_aware_frames(), which in turn calls abort(). // it calls skip_non_cxx_eh_aware_frames(), which in turn calls abort().
_LIBCXXABI_FUNC_VIS uintptr_t __xlc_exception_handle() { _LIBCXXABI_FUNC_VIS uintptr_t __xlc_exception_handle() {
// Get the SP of this function, i.e., __xlc_exception_handle(). // Get the SP of this function, i.e., __xlc_exception_handle().

View File

@ -207,7 +207,12 @@ void __cxa_free_exception(void *thrown_object) throw() {
} }
__cxa_exception* __cxa_init_primary_exception(void* object, std::type_info* tinfo, __cxa_exception* __cxa_init_primary_exception(void* object, std::type_info* tinfo,
#ifdef __wasm__
// In Wasm, a destructor returns its argument
void *(_LIBCXXABI_DTOR_FUNC* dest)(void*)) throw() {
#else
void(_LIBCXXABI_DTOR_FUNC* dest)(void*)) throw() { void(_LIBCXXABI_DTOR_FUNC* dest)(void*)) throw() {
#endif
__cxa_exception* exception_header = cxa_exception_from_thrown_object(object); __cxa_exception* exception_header = cxa_exception_from_thrown_object(object);
exception_header->referenceCount = 0; exception_header->referenceCount = 0;
exception_header->unexpectedHandler = std::get_unexpected(); exception_header->unexpectedHandler = std::get_unexpected();
@ -267,7 +272,7 @@ will call terminate, assuming that there was no handler for the
exception. exception.
*/ */
void void
#ifdef __USING_WASM_EXCEPTIONS__ #ifdef __wasm__
// In Wasm, a destructor returns its argument // In Wasm, a destructor returns its argument
__cxa_throw(void *thrown_object, std::type_info *tinfo, void *(_LIBCXXABI_DTOR_FUNC *dest)(void *)) { __cxa_throw(void *thrown_object, std::type_info *tinfo, void *(_LIBCXXABI_DTOR_FUNC *dest)(void *)) {
#else #else
@ -584,6 +589,11 @@ void __cxa_end_catch() {
} }
} }
void __cxa_call_terminate(void* unwind_arg) throw() {
__cxa_begin_catch(unwind_arg);
std::terminate();
}
// Note: exception_header may be masquerading as a __cxa_dependent_exception // Note: exception_header may be masquerading as a __cxa_dependent_exception
// and that's ok. exceptionType is there too. // and that's ok. exceptionType is there too.
// However watch out for foreign exceptions. Return null for them. // However watch out for foreign exceptions. Return null for them.

View File

@ -43,7 +43,7 @@ struct _LIBCXXABI_HIDDEN __cxa_exception {
// Manage the exception object itself. // Manage the exception object itself.
std::type_info *exceptionType; std::type_info *exceptionType;
#ifdef __USING_WASM_EXCEPTIONS__ #ifdef __wasm__
// In Wasm, a destructor returns its argument // In Wasm, a destructor returns its argument
void *(_LIBCXXABI_DTOR_FUNC *exceptionDestructor)(void *); void *(_LIBCXXABI_DTOR_FUNC *exceptionDestructor)(void *);
#else #else

View File

@ -12,7 +12,7 @@
#include "cxa_exception.h" #include "cxa_exception.h"
#include <__threading_support> #include <__thread/support.h>
#if defined(_LIBCXXABI_HAS_NO_THREADS) #if defined(_LIBCXXABI_HAS_NO_THREADS)
@ -24,7 +24,7 @@ extern "C" {
} // extern "C" } // extern "C"
} // namespace __cxxabiv1 } // namespace __cxxabiv1
#elif defined(HAS_THREAD_LOCAL) #elif __has_feature(cxx_thread_local)
namespace __cxxabiv1 { namespace __cxxabiv1 {
namespace { namespace {

View File

@ -58,7 +58,7 @@
# endif # endif
#endif #endif
#include <__threading_support> #include <__thread/support.h>
#include <cstdint> #include <cstdint>
#include <cstring> #include <cstring>
#include <limits.h> #include <limits.h>

View File

@ -70,7 +70,7 @@ extern "C" EXCEPTION_DISPOSITION _GCC_specific_handler(PEXCEPTION_RECORD,
+------------------+--+-----+-----+------------------------+--------------------------+ +------------------+--+-----+-----+------------------------+--------------------------+
| callSiteTableLength | (ULEB128) | Call Site Table length, used to find Action table | | callSiteTableLength | (ULEB128) | Call Site Table length, used to find Action table |
+---------------------+-----------+---------------------------------------------------+ +---------------------+-----------+---------------------------------------------------+
#if !defined(__USING_SJLJ_EXCEPTIONS__) && !defined(__USING_WASM_EXCEPTIONS__) #if !defined(__USING_SJLJ_EXCEPTIONS__) && !defined(__WASM_EXCEPTIONS__)
+---------------------+-----------+------------------------------------------------+ +---------------------+-----------+------------------------------------------------+
| Beginning of Call Site Table The current ip lies within the | | Beginning of Call Site Table The current ip lies within the |
| ... (start, length) range of one of these | | ... (start, length) range of one of these |
@ -84,7 +84,7 @@ extern "C" EXCEPTION_DISPOSITION _GCC_specific_handler(PEXCEPTION_RECORD,
| +-------------+---------------------------------+------------------------------+ | | +-------------+---------------------------------+------------------------------+ |
| ... | | ... |
+----------------------------------------------------------------------------------+ +----------------------------------------------------------------------------------+
#else // __USING_SJLJ_EXCEPTIONS__ || __USING_WASM_EXCEPTIONS__ #else // __USING_SJLJ_EXCEPTIONS__ || __WASM_EXCEPTIONS__
+---------------------+-----------+------------------------------------------------+ +---------------------+-----------+------------------------------------------------+
| Beginning of Call Site Table The current ip is a 1-based index into | | Beginning of Call Site Table The current ip is a 1-based index into |
| ... this table. Or it is -1 meaning no | | ... this table. Or it is -1 meaning no |
@ -97,7 +97,7 @@ extern "C" EXCEPTION_DISPOSITION _GCC_specific_handler(PEXCEPTION_RECORD,
| +-------------+---------------------------------+------------------------------+ | | +-------------+---------------------------------+------------------------------+ |
| ... | | ... |
+----------------------------------------------------------------------------------+ +----------------------------------------------------------------------------------+
#endif // __USING_SJLJ_EXCEPTIONS__ || __USING_WASM_EXCEPTIONS__ #endif // __USING_SJLJ_EXCEPTIONS__ || __WASM_EXCEPTIONS__
+---------------------------------------------------------------------+ +---------------------------------------------------------------------+
| Beginning of Action Table ttypeIndex == 0 : cleanup | | Beginning of Action Table ttypeIndex == 0 : cleanup |
| ... ttypeIndex > 0 : catch | | ... ttypeIndex > 0 : catch |
@ -547,7 +547,7 @@ void
set_registers(_Unwind_Exception* unwind_exception, _Unwind_Context* context, set_registers(_Unwind_Exception* unwind_exception, _Unwind_Context* context,
const scan_results& results) const scan_results& results)
{ {
#if defined(__USING_SJLJ_EXCEPTIONS__) || defined(__USING_WASM_EXCEPTIONS__) #if defined(__USING_SJLJ_EXCEPTIONS__) || defined(__WASM_EXCEPTIONS__)
#define __builtin_eh_return_data_regno(regno) regno #define __builtin_eh_return_data_regno(regno) regno
#elif defined(__ibmxl__) #elif defined(__ibmxl__)
// IBM xlclang++ compiler does not support __builtin_eh_return_data_regno. // IBM xlclang++ compiler does not support __builtin_eh_return_data_regno.
@ -642,7 +642,7 @@ static void scan_eh_tab(scan_results &results, _Unwind_Action actions,
// Get beginning current frame's code (as defined by the // Get beginning current frame's code (as defined by the
// emitted dwarf code) // emitted dwarf code)
uintptr_t funcStart = _Unwind_GetRegionStart(context); uintptr_t funcStart = _Unwind_GetRegionStart(context);
#if defined(__USING_SJLJ_EXCEPTIONS__) || defined(__USING_WASM_EXCEPTIONS__) #if defined(__USING_SJLJ_EXCEPTIONS__) || defined(__WASM_EXCEPTIONS__)
if (ip == uintptr_t(-1)) if (ip == uintptr_t(-1))
{ {
// no action // no action
@ -652,9 +652,9 @@ static void scan_eh_tab(scan_results &results, _Unwind_Action actions,
else if (ip == 0) else if (ip == 0)
call_terminate(native_exception, unwind_exception); call_terminate(native_exception, unwind_exception);
// ip is 1-based index into call site table // ip is 1-based index into call site table
#else // !__USING_SJLJ_EXCEPTIONS__ && !__USING_WASM_EXCEPTIONS__ #else // !__USING_SJLJ_EXCEPTIONS__ && !__WASM_EXCEPTIONS__
uintptr_t ipOffset = ip - funcStart; uintptr_t ipOffset = ip - funcStart;
#endif // !__USING_SJLJ_EXCEPTIONS__ && !__USING_WASM_EXCEPTIONS__ #endif // !__USING_SJLJ_EXCEPTIONS__ && !__WASM_EXCEPTIONS__
const uint8_t* classInfo = NULL; const uint8_t* classInfo = NULL;
// Note: See JITDwarfEmitter::EmitExceptionTable(...) for corresponding // Note: See JITDwarfEmitter::EmitExceptionTable(...) for corresponding
// dwarf emission // dwarf emission
@ -675,7 +675,7 @@ static void scan_eh_tab(scan_results &results, _Unwind_Action actions,
// Walk call-site table looking for range that // Walk call-site table looking for range that
// includes current PC. // includes current PC.
uint8_t callSiteEncoding = *lsda++; uint8_t callSiteEncoding = *lsda++;
#if defined(__USING_SJLJ_EXCEPTIONS__) || defined(__USING_WASM_EXCEPTIONS__) #if defined(__USING_SJLJ_EXCEPTIONS__) || defined(__WASM_EXCEPTIONS__)
(void)callSiteEncoding; // When using SjLj/Wasm exceptions, callSiteEncoding is never used (void)callSiteEncoding; // When using SjLj/Wasm exceptions, callSiteEncoding is never used
#endif #endif
uint32_t callSiteTableLength = static_cast<uint32_t>(readULEB128(&lsda)); uint32_t callSiteTableLength = static_cast<uint32_t>(readULEB128(&lsda));
@ -686,7 +686,7 @@ static void scan_eh_tab(scan_results &results, _Unwind_Action actions,
while (callSitePtr < callSiteTableEnd) while (callSitePtr < callSiteTableEnd)
{ {
// There is one entry per call site. // There is one entry per call site.
#if !defined(__USING_SJLJ_EXCEPTIONS__) && !defined(__USING_WASM_EXCEPTIONS__) #if !defined(__USING_SJLJ_EXCEPTIONS__) && !defined(__WASM_EXCEPTIONS__)
// The call sites are non-overlapping in [start, start+length) // The call sites are non-overlapping in [start, start+length)
// The call sites are ordered in increasing value of start // The call sites are ordered in increasing value of start
uintptr_t start = readEncodedPointer(&callSitePtr, callSiteEncoding); uintptr_t start = readEncodedPointer(&callSitePtr, callSiteEncoding);
@ -694,15 +694,15 @@ static void scan_eh_tab(scan_results &results, _Unwind_Action actions,
uintptr_t landingPad = readEncodedPointer(&callSitePtr, callSiteEncoding); uintptr_t landingPad = readEncodedPointer(&callSitePtr, callSiteEncoding);
uintptr_t actionEntry = readULEB128(&callSitePtr); uintptr_t actionEntry = readULEB128(&callSitePtr);
if ((start <= ipOffset) && (ipOffset < (start + length))) if ((start <= ipOffset) && (ipOffset < (start + length)))
#else // __USING_SJLJ_EXCEPTIONS__ || __USING_WASM_EXCEPTIONS__ #else // __USING_SJLJ_EXCEPTIONS__ || __WASM_EXCEPTIONS__
// ip is 1-based index into this table // ip is 1-based index into this table
uintptr_t landingPad = readULEB128(&callSitePtr); uintptr_t landingPad = readULEB128(&callSitePtr);
uintptr_t actionEntry = readULEB128(&callSitePtr); uintptr_t actionEntry = readULEB128(&callSitePtr);
if (--ip == 0) if (--ip == 0)
#endif // __USING_SJLJ_EXCEPTIONS__ || __USING_WASM_EXCEPTIONS__ #endif // __USING_SJLJ_EXCEPTIONS__ || __WASM_EXCEPTIONS__
{ {
// Found the call site containing ip. // Found the call site containing ip.
#if !defined(__USING_SJLJ_EXCEPTIONS__) && !defined(__USING_WASM_EXCEPTIONS__) #if !defined(__USING_SJLJ_EXCEPTIONS__) && !defined(__WASM_EXCEPTIONS__)
if (landingPad == 0) if (landingPad == 0)
{ {
// No handler here // No handler here
@ -710,16 +710,14 @@ static void scan_eh_tab(scan_results &results, _Unwind_Action actions,
return; return;
} }
landingPad = (uintptr_t)lpStart + landingPad; landingPad = (uintptr_t)lpStart + landingPad;
#else // __USING_SJLJ_EXCEPTIONS__ || __USING_WASM_EXCEPTIONS__ #else // __USING_SJLJ_EXCEPTIONS__ || __WASM_EXCEPTIONS__
++landingPad; ++landingPad;
#endif // __USING_SJLJ_EXCEPTIONS__ || __USING_WASM_EXCEPTIONS__ #endif // __USING_SJLJ_EXCEPTIONS__ || __WASM_EXCEPTIONS__
results.landingPad = landingPad; results.landingPad = landingPad;
if (actionEntry == 0) if (actionEntry == 0)
{ {
// Found a cleanup // Found a cleanup
results.reason = actions & _UA_SEARCH_PHASE results.reason = (actions & _UA_SEARCH_PHASE) ? _URC_CONTINUE_UNWIND : _URC_HANDLER_FOUND;
? _URC_CONTINUE_UNWIND
: _URC_HANDLER_FOUND;
return; return;
} }
// Convert 1-based byte offset into // Convert 1-based byte offset into
@ -840,7 +838,7 @@ static void scan_eh_tab(scan_results &results, _Unwind_Action actions,
action += actionOffset; action += actionOffset;
} // there is no break out of this loop, only return } // there is no break out of this loop, only return
} }
#if !defined(__USING_SJLJ_EXCEPTIONS__) && !defined(__USING_WASM_EXCEPTIONS__) #if !defined(__USING_SJLJ_EXCEPTIONS__) && !defined(__WASM_EXCEPTIONS__)
else if (ipOffset < start) else if (ipOffset < start)
{ {
// There is no call site for this ip // There is no call site for this ip
@ -848,7 +846,7 @@ static void scan_eh_tab(scan_results &results, _Unwind_Action actions,
// Possible stack corruption. // Possible stack corruption.
call_terminate(native_exception, unwind_exception); call_terminate(native_exception, unwind_exception);
} }
#endif // !__USING_SJLJ_EXCEPTIONS__ && !__USING_WASM_EXCEPTIONS__ #endif // !__USING_SJLJ_EXCEPTIONS__ && !__WASM_EXCEPTIONS__
} // there might be some tricky cases which break out of this loop } // there might be some tricky cases which break out of this loop
// It is possible that no eh table entry specify how to handle // It is possible that no eh table entry specify how to handle
@ -905,7 +903,7 @@ _UA_CLEANUP_PHASE
*/ */
#if !defined(_LIBCXXABI_ARM_EHABI) #if !defined(_LIBCXXABI_ARM_EHABI)
#ifdef __USING_WASM_EXCEPTIONS__ #ifdef __WASM_EXCEPTIONS__
_Unwind_Reason_Code __gxx_personality_wasm0 _Unwind_Reason_Code __gxx_personality_wasm0
#elif defined(__SEH__) && !defined(__USING_SJLJ_EXCEPTIONS__) #elif defined(__SEH__) && !defined(__USING_SJLJ_EXCEPTIONS__)
static _Unwind_Reason_Code __gxx_personality_imp static _Unwind_Reason_Code __gxx_personality_imp
@ -974,7 +972,7 @@ __gxx_personality_v0
exc->languageSpecificData = results.languageSpecificData; exc->languageSpecificData = results.languageSpecificData;
exc->catchTemp = reinterpret_cast<void*>(results.landingPad); exc->catchTemp = reinterpret_cast<void*>(results.landingPad);
exc->adjustedPtr = results.adjustedPtr; exc->adjustedPtr = results.adjustedPtr;
#ifdef __USING_WASM_EXCEPTIONS__ #ifdef __WASM_EXCEPTIONS__
// Wasm only uses a single phase (_UA_SEARCH_PHASE), so save the // Wasm only uses a single phase (_UA_SEARCH_PHASE), so save the
// results here. // results here.
set_registers(unwind_exception, context, results); set_registers(unwind_exception, context, results);

View File

@ -8,7 +8,7 @@
#include "abort_message.h" #include "abort_message.h"
#include "cxxabi.h" #include "cxxabi.h"
#include <__threading_support> #include <__thread/support.h>
#ifndef _LIBCXXABI_HAS_NO_THREADS #ifndef _LIBCXXABI_HAS_NO_THREADS
#if defined(__ELF__) && defined(_LIBCXXABI_LINK_PTHREAD_LIB) #if defined(__ELF__) && defined(_LIBCXXABI_LINK_PTHREAD_LIB)
#pragma comment(lib, "pthread") #pragma comment(lib, "pthread")

View File

@ -39,13 +39,12 @@
DEMANGLE_NAMESPACE_BEGIN DEMANGLE_NAMESPACE_BEGIN
template <class T, size_t N> class PODSmallVector { template <class T, size_t N> class PODSmallVector {
static_assert(std::is_pod<T>::value, static_assert(std::is_trivial<T>::value,
"T is required to be a plain old data type"); "T is required to be a trivial type");
T *First = nullptr; T *First = nullptr;
T *Last = nullptr; T *Last = nullptr;
T *Cap = nullptr; T *Cap = nullptr;
T Inline[N] = {0}; T Inline[N] = {};
bool isInline() const { return First == Inline; } bool isInline() const { return First == Inline; }
@ -5542,7 +5541,7 @@ Node *AbstractManglingParser<Alloc, Derived>::parseFloatingLiteral() {
return nullptr; return nullptr;
std::string_view Data(First, N); std::string_view Data(First, N);
for (char C : Data) for (char C : Data)
if (!std::isxdigit(C)) if (!(C >= '0' && C <= '9') && !(C >= 'a' && C <= 'f'))
return nullptr; return nullptr;
First += N; First += N;
if (!consumeIf('E')) if (!consumeIf('E'))
@ -5716,6 +5715,7 @@ Node *AbstractManglingParser<Derived, Alloc>::parseTemplateParam() {
} }
// <template-param-decl> ::= Ty # type parameter // <template-param-decl> ::= Ty # type parameter
// ::= Tk <concept name> [<template-args>] # constrained type parameter
// ::= Tn <type> # non-type parameter // ::= Tn <type> # non-type parameter
// ::= Tt <template-param-decl>* E # template parameter // ::= Tt <template-param-decl>* E # template parameter
// ::= Tp <template-param-decl> # parameter pack // ::= Tp <template-param-decl> # parameter pack
@ -5847,7 +5847,7 @@ Node *AbstractManglingParser<Derived, Alloc>::parseTemplateArg() {
} }
} }
// <template-args> ::= I <template-arg>* E // <template-args> ::= I <template-arg>* [Q <requires-clause expr>] E
// extension, the abi says <template-arg>+ // extension, the abi says <template-arg>+
template <typename Derived, typename Alloc> template <typename Derived, typename Alloc>
Node * Node *

View File

@ -9,7 +9,7 @@
#include "fallback_malloc.h" #include "fallback_malloc.h"
#include "abort_message.h" #include "abort_message.h"
#include <__threading_support> #include <__thread/support.h>
#ifndef _LIBCXXABI_HAS_NO_THREADS #ifndef _LIBCXXABI_HAS_NO_THREADS
#if defined(__ELF__) && defined(_LIBCXXABI_LINK_PTHREAD_LIB) #if defined(__ELF__) && defined(_LIBCXXABI_LINK_PTHREAD_LIB)
#pragma comment(lib, "pthread") #pragma comment(lib, "pthread")

View File

@ -44,13 +44,25 @@
#include <cstdint> #include <cstdint>
#include <cassert> #include <cassert>
#include <string.h> #include <string.h>
#include "abort_message.h"
#ifdef _LIBCXXABI_FORGIVING_DYNAMIC_CAST #ifdef _LIBCXXABI_FORGIVING_DYNAMIC_CAST
#include "abort_message.h"
#include <sys/syslog.h> #include <sys/syslog.h>
#include <atomic> #include <atomic>
#endif #endif
#if __has_feature(ptrauth_calls)
#include <ptrauth.h>
#endif
template <typename T>
static inline T* strip_vtable(T* vtable) {
#if __has_feature(ptrauth_calls)
vtable = ptrauth_strip(vtable, ptrauth_key_cxx_vtable_pointer);
#endif
return vtable;
}
static inline static inline
bool bool
is_equal(const std::type_info* x, const std::type_info* y, bool use_strcmp) is_equal(const std::type_info* x, const std::type_info* y, bool use_strcmp)
@ -102,10 +114,10 @@ void dyn_cast_get_derived_info(derived_object_info* info, const void* static_ptr
reinterpret_cast<const uint8_t*>(vtable) + offset_to_ti_proxy; reinterpret_cast<const uint8_t*>(vtable) + offset_to_ti_proxy;
info->dynamic_type = *(reinterpret_cast<const __class_type_info* const*>(ptr_to_ti_proxy)); info->dynamic_type = *(reinterpret_cast<const __class_type_info* const*>(ptr_to_ti_proxy));
#else #else
void **vtable = *static_cast<void ** const *>(static_ptr); void** vtable = strip_vtable(*static_cast<void** const*>(static_ptr));
info->offset_to_derived = reinterpret_cast<ptrdiff_t>(vtable[-2]); info->offset_to_derived = reinterpret_cast<ptrdiff_t>(vtable[-2]);
info->dynamic_ptr = static_cast<const char*>(static_ptr) + info->offset_to_derived; info->dynamic_ptr = static_cast<const char*>(static_ptr) + info->offset_to_derived;
info->dynamic_type = static_cast<const __class_type_info*>(vtable[-1]); info->dynamic_type = static_cast<const __class_type_info*>(vtable[-1]);
#endif #endif
} }
@ -470,7 +482,7 @@ __class_type_info::can_catch(const __shim_type_info* thrown_type,
if (thrown_class_type == 0) if (thrown_class_type == 0)
return false; return false;
// bullet 2 // bullet 2
assert(adjustedPtr && "catching a class without an object?"); _LIBCXXABI_ASSERT(adjustedPtr, "catching a class without an object?");
__dynamic_cast_info info = {thrown_class_type, 0, this, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, true, nullptr}; __dynamic_cast_info info = {thrown_class_type, 0, this, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, true, nullptr};
info.number_of_dst_type = 1; info.number_of_dst_type = 1;
thrown_class_type->has_unambiguous_public_base(&info, adjustedPtr, public_path); thrown_class_type->has_unambiguous_public_base(&info, adjustedPtr, public_path);
@ -560,7 +572,7 @@ __base_class_type_info::has_unambiguous_public_base(__dynamic_cast_info* info,
find the layout. */ find the layout. */
offset_to_base = __offset_flags >> __offset_shift; offset_to_base = __offset_flags >> __offset_shift;
if (is_virtual) { if (is_virtual) {
const char* vtable = *static_cast<const char* const*>(adjustedPtr); const char* vtable = strip_vtable(*static_cast<const char* const*>(adjustedPtr));
offset_to_base = update_offset_to_base(vtable, offset_to_base); offset_to_base = update_offset_to_base(vtable, offset_to_base);
} }
} else if (!is_virtual) { } else if (!is_virtual) {
@ -1500,8 +1512,8 @@ __base_class_type_info::search_above_dst(__dynamic_cast_info* info,
ptrdiff_t offset_to_base = __offset_flags >> __offset_shift; ptrdiff_t offset_to_base = __offset_flags >> __offset_shift;
if (__offset_flags & __virtual_mask) if (__offset_flags & __virtual_mask)
{ {
const char* vtable = *static_cast<const char*const*>(current_ptr); const char* vtable = strip_vtable(*static_cast<const char* const*>(current_ptr));
offset_to_base = update_offset_to_base(vtable, offset_to_base); offset_to_base = update_offset_to_base(vtable, offset_to_base);
} }
__base_type->search_above_dst(info, dst_ptr, __base_type->search_above_dst(info, dst_ptr,
static_cast<const char*>(current_ptr) + offset_to_base, static_cast<const char*>(current_ptr) + offset_to_base,
@ -1520,8 +1532,8 @@ __base_class_type_info::search_below_dst(__dynamic_cast_info* info,
ptrdiff_t offset_to_base = __offset_flags >> __offset_shift; ptrdiff_t offset_to_base = __offset_flags >> __offset_shift;
if (__offset_flags & __virtual_mask) if (__offset_flags & __virtual_mask)
{ {
const char* vtable = *static_cast<const char*const*>(current_ptr); const char* vtable = strip_vtable(*static_cast<const char* const*>(current_ptr));
offset_to_base = update_offset_to_base(vtable, offset_to_base); offset_to_base = update_offset_to_base(vtable, offset_to_base);
} }
__base_type->search_below_dst(info, __base_type->search_below_dst(info,
static_cast<const char*>(current_ptr) + offset_to_base, static_cast<const char*>(current_ptr) + offset_to_base,