Path: blob/main/system/lib/libcxxabi/src/cxa_personality.cpp
6173 views
//===----------------------------------------------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//7// This file implements the "Exception Handling APIs"8// https://itanium-cxx-abi.github.io/cxx-abi/abi-eh.html9// http://www.intel.com/design/itanium/downloads/245358.htm10//11//===----------------------------------------------------------------------===//1213#include <assert.h>14#include <stdlib.h>15#include <string.h>16#include <typeinfo>1718#include "__cxxabi_config.h"19#include "cxa_exception.h"20#include "cxa_handlers.h"21#include "private_typeinfo.h"22#include "unwind.h"2324// TODO: This is a temporary workaround for libc++abi to recognize that it's being25// built against LLVM's libunwind. LLVM's libunwind started reporting _LIBUNWIND_VERSION26// in LLVM 15 -- we can remove this workaround after shipping LLVM 17. Once we remove27// this workaround, it won't be possible to build libc++abi against libunwind headers28// from LLVM 14 and before anymore.29#if defined(____LIBUNWIND_CONFIG_H__) && !defined(_LIBUNWIND_VERSION)30# define _LIBUNWIND_VERSION31#endif3233#if defined(__SEH__) && !defined(__USING_SJLJ_EXCEPTIONS__)34#include <windows.h>35#include <winnt.h>3637extern "C" EXCEPTION_DISPOSITION _GCC_specific_handler(PEXCEPTION_RECORD,38void *, PCONTEXT,39PDISPATCHER_CONTEXT,40_Unwind_Personality_Fn);41#endif4243/*44Exception Header Layout:4546+---------------------------+-----------------------------+---------------+47| __cxa_exception | _Unwind_Exception CLNGC++\0 | thrown object |48+---------------------------+-----------------------------+---------------+49^50|51+-------------------------------------------------------+52|53+---------------------------+-----------------------------+54| __cxa_dependent_exception | _Unwind_Exception CLNGC++\1 |55+---------------------------+-----------------------------+5657Exception Handling Table Layout:5859+-----------------+--------+60| lpStartEncoding | (char) |61+---------+-------+--------+---------------+-----------------------+62| lpStart | (encoded with lpStartEncoding) | defaults to funcStart |63+---------+-----+--------+-----------------+---------------+-------+64| ttypeEncoding | (char) | Encoding of the type_info table |65+---------------+-+------+----+----------------------------+----------------+66| classInfoOffset | (ULEB128) | Offset to type_info table, defaults to null |67+-----------------++--------+-+----------------------------+----------------+68| callSiteEncoding | (char) | Encoding for Call Site Table |69+------------------+--+-----+-----+------------------------+--------------------------+70| callSiteTableLength | (ULEB128) | Call Site Table length, used to find Action table |71+---------------------+-----------+---------------------------------------------------+72#if !defined(__USING_SJLJ_EXCEPTIONS__) && !defined(__WASM_EXCEPTIONS__)73+---------------------+-----------+------------------------------------------------+74| Beginning of Call Site Table The current ip lies within the |75| ... (start, length) range of one of these |76| call sites. There may be action needed. |77| +-------------+---------------------------------+------------------------------+ |78| | start | (encoded with callSiteEncoding) | offset relative to funcStart | |79| | length | (encoded with callSiteEncoding) | length of code fragment | |80| | landingPad | (encoded with callSiteEncoding) | offset relative to lpStart | |81| | actionEntry | (ULEB128) | Action Table Index 1-based | |82| | | | actionEntry == 0 -> cleanup | |83| +-------------+---------------------------------+------------------------------+ |84| ... |85+----------------------------------------------------------------------------------+86#else // __USING_SJLJ_EXCEPTIONS__ || __WASM_EXCEPTIONS__87+---------------------+-----------+------------------------------------------------+88| Beginning of Call Site Table The current ip is a 1-based index into |89| ... this table. Or it is -1 meaning no |90| action is needed. Or it is 0 meaning |91| terminate. |92| +-------------+---------------------------------+------------------------------+ |93| | landingPad | (ULEB128) | offset relative to lpStart | |94| | actionEntry | (ULEB128) | Action Table Index 1-based | |95| | | | actionEntry == 0 -> cleanup | |96| +-------------+---------------------------------+------------------------------+ |97| ... |98+----------------------------------------------------------------------------------+99#endif // __USING_SJLJ_EXCEPTIONS__ || __WASM_EXCEPTIONS__100+---------------------------------------------------------------------+101| Beginning of Action Table ttypeIndex == 0 : cleanup |102| ... ttypeIndex > 0 : catch |103| ttypeIndex < 0 : exception spec |104| +--------------+-----------+--------------------------------------+ |105| | ttypeIndex | (SLEB128) | Index into type_info Table (1-based) | |106| | actionOffset | (SLEB128) | Offset into next Action Table entry | |107| +--------------+-----------+--------------------------------------+ |108| ... |109+---------------------------------------------------------------------+-----------------+110| type_info Table, but classInfoOffset does *not* point here! |111| +----------------+------------------------------------------------+-----------------+ |112| | Nth type_info* | Encoded with ttypeEncoding, 0 means catch(...) | ttypeIndex == N | |113| +----------------+------------------------------------------------+-----------------+ |114| ... |115| +----------------+------------------------------------------------+-----------------+ |116| | 1st type_info* | Encoded with ttypeEncoding, 0 means catch(...) | ttypeIndex == 1 | |117| +----------------+------------------------------------------------+-----------------+ |118| +---------------------------------------+-----------+------------------------------+ |119| | 1st ttypeIndex for 1st exception spec | (ULEB128) | classInfoOffset points here! | |120| | ... | (ULEB128) | | |121| | Mth ttypeIndex for 1st exception spec | (ULEB128) | | |122| | 0 | (ULEB128) | | |123| +---------------------------------------+------------------------------------------+ |124| ... |125| +---------------------------------------+------------------------------------------+ |126| | 0 | (ULEB128) | throw() | |127| +---------------------------------------+------------------------------------------+ |128| ... |129| +---------------------------------------+------------------------------------------+ |130| | 1st ttypeIndex for Nth exception spec | (ULEB128) | | |131| | ... | (ULEB128) | | |132| | Mth ttypeIndex for Nth exception spec | (ULEB128) | | |133| | 0 | (ULEB128) | | |134| +---------------------------------------+------------------------------------------+ |135+---------------------------------------------------------------------------------------+136137Notes:138139* ttypeIndex in the Action Table, and in the exception spec table, is an index,140not a byte count, if positive. It is a negative index offset of141classInfoOffset and the sizeof entry depends on ttypeEncoding.142But if ttypeIndex is negative, it is a positive 1-based byte offset into the143type_info Table.144And if ttypeIndex is zero, it refers to a catch (...).145146* landingPad can be 0, this implies there is nothing to be done.147148* landingPad != 0 and actionEntry == 0 implies a cleanup needs to be done149@landingPad.150151* A cleanup can also be found under landingPad != 0 and actionEntry != 0 in152the Action Table with ttypeIndex == 0.153*/154155namespace __cxxabiv1156{157158namespace159{160161template <class AsType>162uintptr_t readPointerHelper(const uint8_t*& p) {163AsType value;164memcpy(&value, p, sizeof(AsType));165p += sizeof(AsType);166return static_cast<uintptr_t>(value);167}168169} // namespace170171extern "C"172{173174// private API175176// Heavily borrowed from llvm/examples/ExceptionDemo/ExceptionDemo.cpp177178// DWARF Constants179enum180{181DW_EH_PE_absptr = 0x00,182DW_EH_PE_uleb128 = 0x01,183DW_EH_PE_udata2 = 0x02,184DW_EH_PE_udata4 = 0x03,185DW_EH_PE_udata8 = 0x04,186DW_EH_PE_sleb128 = 0x09,187DW_EH_PE_sdata2 = 0x0A,188DW_EH_PE_sdata4 = 0x0B,189DW_EH_PE_sdata8 = 0x0C,190DW_EH_PE_pcrel = 0x10,191DW_EH_PE_textrel = 0x20,192DW_EH_PE_datarel = 0x30,193DW_EH_PE_funcrel = 0x40,194DW_EH_PE_aligned = 0x50,195DW_EH_PE_indirect = 0x80,196DW_EH_PE_omit = 0xFF197};198199/// Read a uleb128 encoded value and advance pointer200/// See Variable Length Data Appendix C in:201/// @link http://dwarfstd.org/Dwarf4.pdf @unlink202/// @param data reference variable holding memory pointer to decode from203/// @returns decoded value204static205uintptr_t206readULEB128(const uint8_t** data)207{208uintptr_t result = 0;209uintptr_t shift = 0;210unsigned char byte;211const uint8_t *p = *data;212do213{214byte = *p++;215result |= static_cast<uintptr_t>(byte & 0x7F) << shift;216shift += 7;217} while (byte & 0x80);218*data = p;219return result;220}221222/// Read a sleb128 encoded value and advance pointer223/// See Variable Length Data Appendix C in:224/// @link http://dwarfstd.org/Dwarf4.pdf @unlink225/// @param data reference variable holding memory pointer to decode from226/// @returns decoded value227static228intptr_t229readSLEB128(const uint8_t** data)230{231uintptr_t result = 0;232uintptr_t shift = 0;233unsigned char byte;234const uint8_t *p = *data;235do236{237byte = *p++;238result |= static_cast<uintptr_t>(byte & 0x7F) << shift;239shift += 7;240} while (byte & 0x80);241*data = p;242if ((byte & 0x40) && (shift < (sizeof(result) << 3)))243result |= static_cast<uintptr_t>(~0) << shift;244return static_cast<intptr_t>(result);245}246247/// Read a pointer encoded value and advance pointer248/// See Variable Length Data in:249/// @link http://dwarfstd.org/Dwarf3.pdf @unlink250/// @param data reference variable holding memory pointer to decode from251/// @param encoding dwarf encoding type252/// @param base for adding relative offset, default to 0253/// @returns decoded value254static255uintptr_t256readEncodedPointer(const uint8_t** data, uint8_t encoding, uintptr_t base = 0)257{258uintptr_t result = 0;259if (encoding == DW_EH_PE_omit)260return result;261const uint8_t* p = *data;262// first get value263switch (encoding & 0x0F)264{265case DW_EH_PE_absptr:266result = readPointerHelper<uintptr_t>(p);267break;268case DW_EH_PE_uleb128:269result = readULEB128(&p);270break;271case DW_EH_PE_sleb128:272result = static_cast<uintptr_t>(readSLEB128(&p));273break;274case DW_EH_PE_udata2:275result = readPointerHelper<uint16_t>(p);276break;277case DW_EH_PE_udata4:278result = readPointerHelper<uint32_t>(p);279break;280case DW_EH_PE_udata8:281result = readPointerHelper<uint64_t>(p);282break;283case DW_EH_PE_sdata2:284result = readPointerHelper<int16_t>(p);285break;286case DW_EH_PE_sdata4:287result = readPointerHelper<int32_t>(p);288break;289case DW_EH_PE_sdata8:290result = readPointerHelper<int64_t>(p);291break;292default:293// not supported294abort();295break;296}297// then add relative offset298switch (encoding & 0x70)299{300case DW_EH_PE_absptr:301// do nothing302break;303case DW_EH_PE_pcrel:304if (result)305result += (uintptr_t)(*data);306break;307case DW_EH_PE_datarel:308assert((base != 0) && "DW_EH_PE_datarel is invalid with a base of 0");309if (result)310result += base;311break;312case DW_EH_PE_textrel:313case DW_EH_PE_funcrel:314case DW_EH_PE_aligned:315default:316// not supported317abort();318break;319}320// then apply indirection321if (result && (encoding & DW_EH_PE_indirect))322result = *((uintptr_t*)result);323*data = p;324return result;325}326327static328void329call_terminate(bool native_exception, _Unwind_Exception* unwind_exception)330{331__cxa_begin_catch(unwind_exception);332if (native_exception)333{334// Use the stored terminate_handler if possible335__cxa_exception* exception_header = (__cxa_exception*)(unwind_exception+1) - 1;336std::__terminate(exception_header->terminateHandler);337}338std::terminate();339}340341#if defined(_LIBCXXABI_ARM_EHABI)342static const void* read_target2_value(const void* ptr)343{344uintptr_t offset = *reinterpret_cast<const uintptr_t*>(ptr);345if (!offset)346return 0;347// "ARM EABI provides a TARGET2 relocation to describe these typeinfo348// pointers. The reason being it allows their precise semantics to be349// deferred to the linker. For bare-metal they turn into absolute350// relocations. For linux they turn into GOT-REL relocations."351// https://gcc.gnu.org/ml/gcc-patches/2009-08/msg00264.html352#if defined(LIBCXXABI_BAREMETAL)353return reinterpret_cast<const void*>(reinterpret_cast<uintptr_t>(ptr) +354offset);355#else356return *reinterpret_cast<const void **>(reinterpret_cast<uintptr_t>(ptr) +357offset);358#endif359}360361static const __shim_type_info*362get_shim_type_info(uint64_t ttypeIndex, const uint8_t* classInfo,363uint8_t ttypeEncoding, bool native_exception,364_Unwind_Exception* unwind_exception, uintptr_t /*base*/ = 0)365{366if (classInfo == 0)367{368// this should not happen. Indicates corrupted eh_table.369call_terminate(native_exception, unwind_exception);370}371372assert(((ttypeEncoding == DW_EH_PE_absptr) || // LLVM or GCC 4.6373(ttypeEncoding == DW_EH_PE_pcrel) || // GCC 4.7 baremetal374(ttypeEncoding == (DW_EH_PE_pcrel | DW_EH_PE_indirect))) && // GCC 4.7 linux375"Unexpected TTypeEncoding");376(void)ttypeEncoding;377378const uint8_t* ttypePtr = classInfo - ttypeIndex * sizeof(uintptr_t);379return reinterpret_cast<const __shim_type_info *>(380read_target2_value(ttypePtr));381}382#else // !defined(_LIBCXXABI_ARM_EHABI)383static384const __shim_type_info*385get_shim_type_info(uint64_t ttypeIndex, const uint8_t* classInfo,386uint8_t ttypeEncoding, bool native_exception,387_Unwind_Exception* unwind_exception, uintptr_t base = 0)388{389if (classInfo == 0)390{391// this should not happen. Indicates corrupted eh_table.392call_terminate(native_exception, unwind_exception);393}394switch (ttypeEncoding & 0x0F)395{396case DW_EH_PE_absptr:397ttypeIndex *= sizeof(void*);398break;399case DW_EH_PE_udata2:400case DW_EH_PE_sdata2:401ttypeIndex *= 2;402break;403case DW_EH_PE_udata4:404case DW_EH_PE_sdata4:405ttypeIndex *= 4;406break;407case DW_EH_PE_udata8:408case DW_EH_PE_sdata8:409ttypeIndex *= 8;410break;411default:412// this should not happen. Indicates corrupted eh_table.413call_terminate(native_exception, unwind_exception);414}415classInfo -= ttypeIndex;416return (const __shim_type_info*)readEncodedPointer(&classInfo,417ttypeEncoding, base);418}419#endif // !defined(_LIBCXXABI_ARM_EHABI)420421/*422This is checking a thrown exception type, excpType, against a possibly empty423list of catchType's which make up an exception spec.424425An exception spec acts like a catch handler, but in reverse. This "catch426handler" will catch an excpType if and only if none of the catchType's in427the list will catch a excpType. If any catchType in the list can catch an428excpType, then this exception spec does not catch the excpType.429*/430#if defined(_LIBCXXABI_ARM_EHABI)431static432bool433exception_spec_can_catch(int64_t specIndex, const uint8_t* classInfo,434uint8_t ttypeEncoding, const __shim_type_info* excpType,435void* adjustedPtr, _Unwind_Exception* unwind_exception,436uintptr_t /*base*/ = 0)437{438if (classInfo == 0)439{440// this should not happen. Indicates corrupted eh_table.441call_terminate(false, unwind_exception);442}443444assert(((ttypeEncoding == DW_EH_PE_absptr) || // LLVM or GCC 4.6445(ttypeEncoding == DW_EH_PE_pcrel) || // GCC 4.7 baremetal446(ttypeEncoding == (DW_EH_PE_pcrel | DW_EH_PE_indirect))) && // GCC 4.7 linux447"Unexpected TTypeEncoding");448(void)ttypeEncoding;449450// specIndex is negative of 1-based byte offset into classInfo;451specIndex = -specIndex;452--specIndex;453const void** temp = reinterpret_cast<const void**>(454reinterpret_cast<uintptr_t>(classInfo) +455static_cast<uintptr_t>(specIndex) * sizeof(uintptr_t));456// If any type in the spec list can catch excpType, return false, else return true457// adjustments to adjustedPtr are ignored.458while (true)459{460// ARM EHABI exception specification table (filter table) consists of461// several pointers which will directly point to the type info object462// (instead of ttypeIndex). The table will be terminated with 0.463const void** ttypePtr = temp++;464if (*ttypePtr == 0)465break;466// We can get the __shim_type_info simply by performing a467// R_ARM_TARGET2 relocation, and cast the result to __shim_type_info.468const __shim_type_info* catchType =469static_cast<const __shim_type_info*>(read_target2_value(ttypePtr));470void* tempPtr = adjustedPtr;471if (catchType->can_catch(excpType, tempPtr))472return false;473}474return true;475}476#else477static478bool479exception_spec_can_catch(int64_t specIndex, const uint8_t* classInfo,480uint8_t ttypeEncoding, const __shim_type_info* excpType,481void* adjustedPtr, _Unwind_Exception* unwind_exception,482uintptr_t base = 0)483{484if (classInfo == 0)485{486// this should not happen. Indicates corrupted eh_table.487call_terminate(false, unwind_exception);488}489// specIndex is negative of 1-based byte offset into classInfo;490specIndex = -specIndex;491--specIndex;492const uint8_t* temp = classInfo + specIndex;493// If any type in the spec list can catch excpType, return false, else return true494// adjustments to adjustedPtr are ignored.495while (true)496{497uint64_t ttypeIndex = readULEB128(&temp);498if (ttypeIndex == 0)499break;500const __shim_type_info* catchType = get_shim_type_info(ttypeIndex,501classInfo,502ttypeEncoding,503true,504unwind_exception,505base);506void* tempPtr = adjustedPtr;507if (catchType->can_catch(excpType, tempPtr))508return false;509}510return true;511}512#endif513514static515void*516get_thrown_object_ptr(_Unwind_Exception* unwind_exception)517{518// Even for foreign exceptions, the exception object is *probably* at unwind_exception + 1519// Regardless, this library is prohibited from touching a foreign exception520void* adjustedPtr = unwind_exception + 1;521if (__getExceptionClass(unwind_exception) == kOurDependentExceptionClass)522adjustedPtr = ((__cxa_dependent_exception*)adjustedPtr - 1)->primaryException;523return adjustedPtr;524}525526namespace527{528529struct scan_results530{531int64_t ttypeIndex; // > 0 catch handler, < 0 exception spec handler, == 0 a cleanup532const uint8_t* actionRecord; // Currently unused. Retained to ease future maintenance.533const uint8_t* languageSpecificData; // Needed only for __cxa_call_unexpected534uintptr_t landingPad; // null -> nothing found, else something found535void* adjustedPtr; // Used in cxa_exception.cpp536_Unwind_Reason_Code reason; // One of _URC_FATAL_PHASE1_ERROR,537// _URC_FATAL_PHASE2_ERROR,538// _URC_CONTINUE_UNWIND,539// _URC_HANDLER_FOUND540};541542} // unnamed namespace543544static545void546set_registers(_Unwind_Exception* unwind_exception, _Unwind_Context* context,547const scan_results& results)548{549#if defined(__USING_SJLJ_EXCEPTIONS__) || defined(__WASM_EXCEPTIONS__)550#define __builtin_eh_return_data_regno(regno) regno551#elif defined(__ibmxl__)552// IBM xlclang++ compiler does not support __builtin_eh_return_data_regno.553#define __builtin_eh_return_data_regno(regno) regno + 3554#endif555_Unwind_SetGR(context, __builtin_eh_return_data_regno(0),556reinterpret_cast<uintptr_t>(unwind_exception));557_Unwind_SetGR(context, __builtin_eh_return_data_regno(1),558static_cast<uintptr_t>(results.ttypeIndex));559_Unwind_SetIP(context, results.landingPad);560}561562/*563There are 3 types of scans needed:5645651. Scan for handler with native or foreign exception. If handler found,566save state and return _URC_HANDLER_FOUND, else return _URC_CONTINUE_UNWIND.567May also report an error on invalid input.568May terminate for invalid exception table.569_UA_SEARCH_PHASE5705712. Scan for handler with foreign exception. Must return _URC_HANDLER_FOUND,572or call terminate.573_UA_CLEANUP_PHASE && _UA_HANDLER_FRAME && !native_exception5745753. Scan for cleanups. If a handler is found and this isn't forced unwind,576then terminate, otherwise ignore the handler and keep looking for cleanup.577If a cleanup is found, return _URC_HANDLER_FOUND, else return _URC_CONTINUE_UNWIND.578May also report an error on invalid input.579May terminate for invalid exception table.580_UA_CLEANUP_PHASE && !_UA_HANDLER_FRAME581*/582583static void scan_eh_tab(scan_results &results, _Unwind_Action actions,584bool native_exception,585_Unwind_Exception *unwind_exception,586_Unwind_Context *context) {587// Initialize results to found nothing but an error588results.ttypeIndex = 0;589results.actionRecord = 0;590results.languageSpecificData = 0;591results.landingPad = 0;592results.adjustedPtr = 0;593results.reason = _URC_FATAL_PHASE1_ERROR;594// Check for consistent actions595if (actions & _UA_SEARCH_PHASE)596{597// Do Phase 1598if (actions & (_UA_CLEANUP_PHASE | _UA_HANDLER_FRAME | _UA_FORCE_UNWIND))599{600// None of these flags should be set during Phase 1601// Client error602results.reason = _URC_FATAL_PHASE1_ERROR;603return;604}605}606else if (actions & _UA_CLEANUP_PHASE)607{608if ((actions & _UA_HANDLER_FRAME) && (actions & _UA_FORCE_UNWIND))609{610// _UA_HANDLER_FRAME should only be set if phase 1 found a handler.611// If _UA_FORCE_UNWIND is set, phase 1 shouldn't have happened.612// Client error613results.reason = _URC_FATAL_PHASE2_ERROR;614return;615}616}617else // Neither _UA_SEARCH_PHASE nor _UA_CLEANUP_PHASE is set618{619// One of these should be set.620// Client error621results.reason = _URC_FATAL_PHASE1_ERROR;622return;623}624// Start scan by getting exception table address.625const uint8_t *lsda = (const uint8_t *)_Unwind_GetLanguageSpecificData(context);626if (lsda == 0)627{628// There is no exception table629results.reason = _URC_CONTINUE_UNWIND;630return;631}632results.languageSpecificData = lsda;633#if defined(_AIX)634uintptr_t base = _Unwind_GetDataRelBase(context);635#else636uintptr_t base = 0;637#endif638// Get the current instruction pointer and offset it before next639// instruction in the current frame which threw the exception.640uintptr_t ip = _Unwind_GetIP(context) - 1;641// Get beginning current frame's code (as defined by the642// emitted dwarf code)643uintptr_t funcStart = _Unwind_GetRegionStart(context);644#if defined(__USING_SJLJ_EXCEPTIONS__) || defined(__WASM_EXCEPTIONS__)645if (ip == uintptr_t(-1))646{647// no action648results.reason = _URC_CONTINUE_UNWIND;649return;650}651else if (ip == 0)652call_terminate(native_exception, unwind_exception);653// ip is 1-based index into call site table654#else // !__USING_SJLJ_EXCEPTIONS__ && !__WASM_EXCEPTIONS__655uintptr_t ipOffset = ip - funcStart;656#endif // !__USING_SJLJ_EXCEPTIONS__ && !__WASM_EXCEPTIONS__657const uint8_t* classInfo = NULL;658// Note: See JITDwarfEmitter::EmitExceptionTable(...) for corresponding659// dwarf emission660// Parse LSDA header.661uint8_t lpStartEncoding = *lsda++;662const uint8_t* lpStart = lpStartEncoding == DW_EH_PE_omit663? (const uint8_t*)funcStart664: (const uint8_t*)readEncodedPointer(&lsda, lpStartEncoding, base);665(void)(lpStart); // Unused when using SjLj/Wasm exceptions666uint8_t ttypeEncoding = *lsda++;667if (ttypeEncoding != DW_EH_PE_omit)668{669// Calculate type info locations in emitted dwarf code which670// were flagged by type info arguments to llvm.eh.selector671// intrinsic672uintptr_t classInfoOffset = readULEB128(&lsda);673classInfo = lsda + classInfoOffset;674}675// Walk call-site table looking for range that676// includes current PC.677uint8_t callSiteEncoding = *lsda++;678#if defined(__USING_SJLJ_EXCEPTIONS__) || defined(__WASM_EXCEPTIONS__)679(void)callSiteEncoding; // Unused when using SjLj/Wasm exceptions680#endif681uint32_t callSiteTableLength = static_cast<uint32_t>(readULEB128(&lsda));682const uint8_t* callSiteTableStart = lsda;683const uint8_t* callSiteTableEnd = callSiteTableStart + callSiteTableLength;684const uint8_t* actionTableStart = callSiteTableEnd;685const uint8_t* callSitePtr = callSiteTableStart;686while (callSitePtr < callSiteTableEnd)687{688// There is one entry per call site.689#if !defined(__USING_SJLJ_EXCEPTIONS__) && !defined(__WASM_EXCEPTIONS__)690// The call sites are non-overlapping in [start, start+length)691// The call sites are ordered in increasing value of start692uintptr_t start = readEncodedPointer(&callSitePtr, callSiteEncoding);693uintptr_t length = readEncodedPointer(&callSitePtr, callSiteEncoding);694uintptr_t landingPad = readEncodedPointer(&callSitePtr, callSiteEncoding);695uintptr_t actionEntry = readULEB128(&callSitePtr);696if ((start <= ipOffset) && (ipOffset < (start + length)))697#else // __USING_SJLJ_EXCEPTIONS__ || __WASM_EXCEPTIONS__698// ip is 1-based index into this table699uintptr_t landingPad = readULEB128(&callSitePtr);700uintptr_t actionEntry = readULEB128(&callSitePtr);701if (--ip == 0)702#endif // __USING_SJLJ_EXCEPTIONS__ || __WASM_EXCEPTIONS__703{704// Found the call site containing ip.705#if !defined(__USING_SJLJ_EXCEPTIONS__) && !defined(__WASM_EXCEPTIONS__)706if (landingPad == 0)707{708// No handler here709results.reason = _URC_CONTINUE_UNWIND;710return;711}712landingPad = (uintptr_t)lpStart + landingPad;713#else // __USING_SJLJ_EXCEPTIONS__ || __WASM_EXCEPTIONS__714++landingPad;715#endif // __USING_SJLJ_EXCEPTIONS__ || __WASM_EXCEPTIONS__716results.landingPad = landingPad;717if (actionEntry == 0)718{719// Found a cleanup720results.reason = (actions & _UA_SEARCH_PHASE) ? _URC_CONTINUE_UNWIND : _URC_HANDLER_FOUND;721return;722}723// Convert 1-based byte offset into724const uint8_t* action = actionTableStart + (actionEntry - 1);725bool hasCleanup = false;726// Scan action entries until you find a matching handler, cleanup, or the end of action list727while (true)728{729const uint8_t* actionRecord = action;730int64_t ttypeIndex = readSLEB128(&action);731if (ttypeIndex > 0)732{733// Found a catch, does it actually catch?734// First check for catch (...)735const __shim_type_info* catchType =736get_shim_type_info(static_cast<uint64_t>(ttypeIndex),737classInfo, ttypeEncoding,738native_exception, unwind_exception,739base);740if (catchType == 0)741{742// Found catch (...) catches everything, including743// foreign exceptions. This is search phase, cleanup744// phase with foreign exception, or forced unwinding.745assert(actions & (_UA_SEARCH_PHASE | _UA_HANDLER_FRAME |746_UA_FORCE_UNWIND));747results.ttypeIndex = ttypeIndex;748results.actionRecord = actionRecord;749results.adjustedPtr =750get_thrown_object_ptr(unwind_exception);751results.reason = _URC_HANDLER_FOUND;752return;753}754// Else this is a catch (T) clause and will never755// catch a foreign exception756else if (native_exception)757{758__cxa_exception* exception_header = (__cxa_exception*)(unwind_exception+1) - 1;759void* adjustedPtr = get_thrown_object_ptr(unwind_exception);760const __shim_type_info* excpType =761static_cast<const __shim_type_info*>(exception_header->exceptionType);762if (adjustedPtr == 0 || excpType == 0)763{764// Something very bad happened765call_terminate(native_exception, unwind_exception);766}767if (catchType->can_catch(excpType, adjustedPtr))768{769// Found a matching handler. This is either search770// phase or forced unwinding.771assert(actions &772(_UA_SEARCH_PHASE | _UA_FORCE_UNWIND));773results.ttypeIndex = ttypeIndex;774results.actionRecord = actionRecord;775results.adjustedPtr = adjustedPtr;776results.reason = _URC_HANDLER_FOUND;777return;778}779}780// Scan next action ...781}782else if (ttypeIndex < 0)783{784// Found an exception specification.785if (actions & _UA_FORCE_UNWIND) {786// Skip if forced unwinding.787} else if (native_exception) {788// Does the exception spec catch this native exception?789__cxa_exception* exception_header = (__cxa_exception*)(unwind_exception+1) - 1;790void* adjustedPtr = get_thrown_object_ptr(unwind_exception);791const __shim_type_info* excpType =792static_cast<const __shim_type_info*>(exception_header->exceptionType);793if (adjustedPtr == 0 || excpType == 0)794{795// Something very bad happened796call_terminate(native_exception, unwind_exception);797}798if (exception_spec_can_catch(ttypeIndex, classInfo,799ttypeEncoding, excpType,800adjustedPtr,801unwind_exception, base))802{803// Native exception caught by exception804// specification.805assert(actions & _UA_SEARCH_PHASE);806results.ttypeIndex = ttypeIndex;807results.actionRecord = actionRecord;808results.adjustedPtr = adjustedPtr;809results.reason = _URC_HANDLER_FOUND;810return;811}812} else {813// foreign exception caught by exception spec814results.ttypeIndex = ttypeIndex;815results.actionRecord = actionRecord;816results.adjustedPtr =817get_thrown_object_ptr(unwind_exception);818results.reason = _URC_HANDLER_FOUND;819return;820}821// Scan next action ...822} else {823hasCleanup = true;824}825const uint8_t* temp = action;826int64_t actionOffset = readSLEB128(&temp);827if (actionOffset == 0)828{829// End of action list. If this is phase 2 and we have found830// a cleanup (ttypeIndex=0), return _URC_HANDLER_FOUND;831// otherwise return _URC_CONTINUE_UNWIND.832results.reason = hasCleanup && actions & _UA_CLEANUP_PHASE833? _URC_HANDLER_FOUND834: _URC_CONTINUE_UNWIND;835return;836}837// Go to next action838action += actionOffset;839} // there is no break out of this loop, only return840}841#if !defined(__USING_SJLJ_EXCEPTIONS__) && !defined(__WASM_EXCEPTIONS__)842else if (ipOffset < start)843{844// There is no call site for this ip845// Something bad has happened. We should never get here.846// Possible stack corruption.847call_terminate(native_exception, unwind_exception);848}849#endif // !__USING_SJLJ_EXCEPTIONS__ && !__WASM_EXCEPTIONS__850} // there might be some tricky cases which break out of this loop851852// It is possible that no eh table entry specify how to handle853// this exception. By spec, terminate it immediately.854call_terminate(native_exception, unwind_exception);855}856857// public API858859/*860The personality function branches on actions like so:861862_UA_SEARCH_PHASE863864If _UA_CLEANUP_PHASE or _UA_HANDLER_FRAME or _UA_FORCE_UNWIND there's865an error from above, return _URC_FATAL_PHASE1_ERROR.866867Scan for anything that could stop unwinding:8688691. A catch clause that will catch this exception870(will never catch foreign).8712. A catch (...) (will always catch foreign).8723. An exception spec that will catch this exception873(will always catch foreign).874If a handler is found875If not foreign876Save state in header877return _URC_HANDLER_FOUND878Else a handler not found879return _URC_CONTINUE_UNWIND880881_UA_CLEANUP_PHASE882883If _UA_HANDLER_FRAME884If _UA_FORCE_UNWIND885How did this happen? return _URC_FATAL_PHASE2_ERROR886If foreign887Do _UA_SEARCH_PHASE to recover state888else889Recover state from header890Transfer control to landing pad. return _URC_INSTALL_CONTEXT891892Else893894This branch handles both normal C++ non-catching handlers (cleanups)895and forced unwinding.896Scan for anything that can not stop unwinding:8978981. A cleanup.899900If a cleanup is found901transfer control to it. return _URC_INSTALL_CONTEXT902Else a cleanup is not found: return _URC_CONTINUE_UNWIND903*/904905#if !defined(_LIBCXXABI_ARM_EHABI)906#ifdef __WASM_EXCEPTIONS__907_Unwind_Reason_Code __gxx_personality_wasm0908#elif defined(__SEH__) && !defined(__USING_SJLJ_EXCEPTIONS__)909static _Unwind_Reason_Code __gxx_personality_imp910#else911_LIBCXXABI_FUNC_VIS _Unwind_Reason_Code912#ifdef __USING_SJLJ_EXCEPTIONS__913__gxx_personality_sj0914#elif defined(__MVS__)915__zos_cxx_personality_v2916#else917__gxx_personality_v0918#endif919#endif920(int version, _Unwind_Action actions, uint64_t exceptionClass,921_Unwind_Exception* unwind_exception, _Unwind_Context* context)922{923if (version != 1 || unwind_exception == 0 || context == 0)924return _URC_FATAL_PHASE1_ERROR;925926bool native_exception = (exceptionClass & get_vendor_and_language) ==927(kOurExceptionClass & get_vendor_and_language);928scan_results results;929// Process a catch handler for a native exception first.930if (actions == (_UA_CLEANUP_PHASE | _UA_HANDLER_FRAME) &&931native_exception) {932// Reload the results from the phase 1 cache.933__cxa_exception* exception_header =934(__cxa_exception*)(unwind_exception + 1) - 1;935results.ttypeIndex = exception_header->handlerSwitchValue;936results.actionRecord = exception_header->actionRecord;937results.languageSpecificData = exception_header->languageSpecificData;938results.landingPad =939reinterpret_cast<uintptr_t>(exception_header->catchTemp);940results.adjustedPtr = exception_header->adjustedPtr;941942// Jump to the handler.943set_registers(unwind_exception, context, results);944// Cache base for calculating the address of ttype in945// __cxa_call_unexpected.946if (results.ttypeIndex < 0) {947#if defined(_AIX)948exception_header->catchTemp = (void *)_Unwind_GetDataRelBase(context);949#else950exception_header->catchTemp = 0;951#endif952}953return _URC_INSTALL_CONTEXT;954}955956// In other cases we need to scan LSDA.957scan_eh_tab(results, actions, native_exception, unwind_exception, context);958if (results.reason == _URC_CONTINUE_UNWIND ||959results.reason == _URC_FATAL_PHASE1_ERROR)960return results.reason;961962if (actions & _UA_SEARCH_PHASE)963{964// Phase 1 search: All we're looking for in phase 1 is a handler that965// halts unwinding966assert(results.reason == _URC_HANDLER_FOUND);967if (native_exception) {968// For a native exception, cache the LSDA result.969__cxa_exception* exc = (__cxa_exception*)(unwind_exception + 1) - 1;970exc->handlerSwitchValue = static_cast<int>(results.ttypeIndex);971exc->actionRecord = results.actionRecord;972exc->languageSpecificData = results.languageSpecificData;973exc->catchTemp = reinterpret_cast<void*>(results.landingPad);974exc->adjustedPtr = results.adjustedPtr;975#ifdef __WASM_EXCEPTIONS__976// Wasm only uses a single phase (_UA_SEARCH_PHASE), so save the977// results here.978set_registers(unwind_exception, context, results);979#endif980}981return _URC_HANDLER_FOUND;982}983984assert(actions & _UA_CLEANUP_PHASE);985assert(results.reason == _URC_HANDLER_FOUND);986set_registers(unwind_exception, context, results);987// Cache base for calculating the address of ttype in __cxa_call_unexpected.988if (results.ttypeIndex < 0) {989__cxa_exception* exception_header =990(__cxa_exception*)(unwind_exception + 1) - 1;991#if defined(_AIX)992exception_header->catchTemp = (void *)_Unwind_GetDataRelBase(context);993#else994exception_header->catchTemp = 0;995#endif996}997return _URC_INSTALL_CONTEXT;998}9991000#if defined(__SEH__) && !defined(__USING_SJLJ_EXCEPTIONS__)1001extern "C" _LIBCXXABI_FUNC_VIS EXCEPTION_DISPOSITION1002__gxx_personality_seh0(PEXCEPTION_RECORD ms_exc, void *this_frame,1003PCONTEXT ms_orig_context, PDISPATCHER_CONTEXT ms_disp)1004{1005return _GCC_specific_handler(ms_exc, this_frame, ms_orig_context, ms_disp,1006__gxx_personality_imp);1007}1008#endif10091010#else10111012extern "C" _Unwind_Reason_Code __gnu_unwind_frame(_Unwind_Exception*,1013_Unwind_Context*);10141015// Helper function to unwind one frame.1016// ARM EHABI 7.3 and 7.4: If the personality function returns _URC_CONTINUE_UNWIND, the1017// personality routine should update the virtual register set (VRS) according to the1018// corresponding frame unwinding instructions (ARM EHABI 9.3.)1019static _Unwind_Reason_Code continue_unwind(_Unwind_Exception* unwind_exception,1020_Unwind_Context* context)1021{1022switch (__gnu_unwind_frame(unwind_exception, context)) {1023case _URC_OK:1024return _URC_CONTINUE_UNWIND;1025case _URC_END_OF_STACK:1026return _URC_END_OF_STACK;1027default:1028return _URC_FAILURE;1029}1030}10311032// ARM register names1033#if !defined(_LIBUNWIND_VERSION)1034static const uint32_t REG_UCB = 12; // Register to save _Unwind_Control_Block1035#endif1036static const uint32_t REG_SP = 13;10371038static void save_results_to_barrier_cache(_Unwind_Exception* unwind_exception,1039const scan_results& results)1040{1041unwind_exception->barrier_cache.bitpattern[0] = (uint32_t)results.adjustedPtr;1042unwind_exception->barrier_cache.bitpattern[1] = (uint32_t)results.actionRecord;1043unwind_exception->barrier_cache.bitpattern[2] = (uint32_t)results.languageSpecificData;1044unwind_exception->barrier_cache.bitpattern[3] = (uint32_t)results.landingPad;1045unwind_exception->barrier_cache.bitpattern[4] = (uint32_t)results.ttypeIndex;1046}10471048static void load_results_from_barrier_cache(scan_results& results,1049const _Unwind_Exception* unwind_exception)1050{1051results.adjustedPtr = (void*)unwind_exception->barrier_cache.bitpattern[0];1052results.actionRecord = (const uint8_t*)unwind_exception->barrier_cache.bitpattern[1];1053results.languageSpecificData = (const uint8_t*)unwind_exception->barrier_cache.bitpattern[2];1054results.landingPad = (uintptr_t)unwind_exception->barrier_cache.bitpattern[3];1055results.ttypeIndex = (int64_t)(int32_t)unwind_exception->barrier_cache.bitpattern[4];1056}10571058extern "C" _LIBCXXABI_FUNC_VIS _Unwind_Reason_Code1059__gxx_personality_v0(_Unwind_State state,1060_Unwind_Exception* unwind_exception,1061_Unwind_Context* context)1062{1063if (unwind_exception == 0 || context == 0)1064return _URC_FATAL_PHASE1_ERROR;10651066bool native_exception = __isOurExceptionClass(unwind_exception);10671068#if !defined(_LIBUNWIND_VERSION)1069// Copy the address of _Unwind_Control_Block to r12 so that1070// _Unwind_GetLanguageSpecificData() and _Unwind_GetRegionStart() can1071// return correct address.1072_Unwind_SetGR(context, REG_UCB, reinterpret_cast<uint32_t>(unwind_exception));1073#endif10741075// Check the undocumented force unwinding behavior1076bool is_force_unwinding = state & _US_FORCE_UNWIND;1077state &= ~_US_FORCE_UNWIND;10781079scan_results results;1080switch (state) {1081case _US_VIRTUAL_UNWIND_FRAME:1082if (is_force_unwinding)1083return continue_unwind(unwind_exception, context);10841085// Phase 1 search: All we're looking for in phase 1 is a handler that halts unwinding1086scan_eh_tab(results, _UA_SEARCH_PHASE, native_exception, unwind_exception, context);1087if (results.reason == _URC_HANDLER_FOUND)1088{1089unwind_exception->barrier_cache.sp = _Unwind_GetGR(context, REG_SP);1090if (native_exception)1091save_results_to_barrier_cache(unwind_exception, results);1092return _URC_HANDLER_FOUND;1093}1094// Did not find the catch handler1095if (results.reason == _URC_CONTINUE_UNWIND)1096return continue_unwind(unwind_exception, context);1097return results.reason;10981099case _US_UNWIND_FRAME_STARTING:1100// TODO: Support force unwinding in the phase 2 search.1101// NOTE: In order to call the cleanup functions, _Unwind_ForcedUnwind()1102// will call this personality function with (_US_FORCE_UNWIND |1103// _US_UNWIND_FRAME_STARTING).11041105// Phase 2 search1106if (unwind_exception->barrier_cache.sp == _Unwind_GetGR(context, REG_SP))1107{1108// Found a catching handler in phase 11109if (native_exception)1110{1111// Load the result from the native exception barrier cache.1112load_results_from_barrier_cache(results, unwind_exception);1113results.reason = _URC_HANDLER_FOUND;1114}1115else1116{1117// Search for the catching handler again for the foreign exception.1118scan_eh_tab(results, static_cast<_Unwind_Action>(_UA_CLEANUP_PHASE | _UA_HANDLER_FRAME),1119native_exception, unwind_exception, context);1120if (results.reason != _URC_HANDLER_FOUND) // phase1 search should guarantee to find one1121call_terminate(native_exception, unwind_exception);1122}11231124// Install the context for the catching handler1125set_registers(unwind_exception, context, results);1126return _URC_INSTALL_CONTEXT;1127}11281129// Either we didn't do a phase 1 search (due to forced unwinding), or1130// phase 1 reported no catching-handlers.1131// Search for a (non-catching) cleanup1132if (is_force_unwinding)1133scan_eh_tab(1134results,1135static_cast<_Unwind_Action>(_UA_CLEANUP_PHASE | _UA_FORCE_UNWIND),1136native_exception, unwind_exception, context);1137else1138scan_eh_tab(results, _UA_CLEANUP_PHASE, native_exception,1139unwind_exception, context);1140if (results.reason == _URC_HANDLER_FOUND)1141{1142// Found a non-catching handler11431144// ARM EHABI 8.4.2: Before we can jump to the cleanup handler, we have to setup some1145// internal data structures, so that __cxa_end_cleanup() can get unwind_exception from1146// __cxa_get_globals().1147__cxa_begin_cleanup(unwind_exception);11481149// Install the context for the cleanup handler1150set_registers(unwind_exception, context, results);1151return _URC_INSTALL_CONTEXT;1152}11531154// Did not find any handler1155if (results.reason == _URC_CONTINUE_UNWIND)1156return continue_unwind(unwind_exception, context);1157return results.reason;11581159case _US_UNWIND_FRAME_RESUME:1160return continue_unwind(unwind_exception, context);1161}11621163// We were called improperly: neither a phase 1 or phase 2 search1164return _URC_FATAL_PHASE1_ERROR;1165}1166#endif116711681169__attribute__((noreturn))1170_LIBCXXABI_FUNC_VIS void1171__cxa_call_unexpected(void* arg)1172{1173_Unwind_Exception* unwind_exception = static_cast<_Unwind_Exception*>(arg);1174if (unwind_exception == 0)1175call_terminate(false, unwind_exception);1176__cxa_begin_catch(unwind_exception);1177bool native_old_exception = __isOurExceptionClass(unwind_exception);1178std::unexpected_handler u_handler;1179std::terminate_handler t_handler;1180__cxa_exception* old_exception_header = 0;1181int64_t ttypeIndex;1182const uint8_t* lsda;1183uintptr_t base = 0;11841185if (native_old_exception)1186{1187old_exception_header = (__cxa_exception*)(unwind_exception+1) - 1;1188t_handler = old_exception_header->terminateHandler;1189u_handler = old_exception_header->unexpectedHandler;1190// If std::__unexpected(u_handler) rethrows the same exception,1191// these values get overwritten by the rethrow. So save them now:1192#if defined(_LIBCXXABI_ARM_EHABI)1193ttypeIndex = (int64_t)(int32_t)unwind_exception->barrier_cache.bitpattern[4];1194lsda = (const uint8_t*)unwind_exception->barrier_cache.bitpattern[2];1195#else1196ttypeIndex = old_exception_header->handlerSwitchValue;1197lsda = old_exception_header->languageSpecificData;1198base = (uintptr_t)old_exception_header->catchTemp;1199#endif1200}1201else1202{1203t_handler = std::get_terminate();1204u_handler = std::get_unexpected();1205}1206try1207{1208std::__unexpected(u_handler);1209}1210catch (...)1211{1212// If the old exception is foreign, then all we can do is terminate.1213// We have no way to recover the needed old exception spec. There's1214// no way to pass that information here. And the personality routine1215// can't call us directly and do anything but terminate() if we throw1216// from here.1217if (native_old_exception)1218{1219// Have:1220// old_exception_header->languageSpecificData1221// old_exception_header->actionRecord1222// old_exception_header->catchTemp, base for calculating ttype1223// Need1224// const uint8_t* classInfo1225// uint8_t ttypeEncoding1226uint8_t lpStartEncoding = *lsda++;1227const uint8_t* lpStart =1228(const uint8_t*)readEncodedPointer(&lsda, lpStartEncoding, base);1229(void)lpStart; // purposefully unused. Just needed to increment lsda.1230uint8_t ttypeEncoding = *lsda++;1231if (ttypeEncoding == DW_EH_PE_omit)1232std::__terminate(t_handler);1233uintptr_t classInfoOffset = readULEB128(&lsda);1234const uint8_t* classInfo = lsda + classInfoOffset;1235// Is this new exception catchable by the exception spec at ttypeIndex?1236// The answer is obviously yes if the new and old exceptions are the same exception1237// If no1238// throw;1239__cxa_eh_globals* globals = __cxa_get_globals_fast();1240__cxa_exception* new_exception_header = globals->caughtExceptions;1241if (new_exception_header == 0)1242// This shouldn't be able to happen!1243std::__terminate(t_handler);1244bool native_new_exception = __isOurExceptionClass(&new_exception_header->unwindHeader);1245void* adjustedPtr;1246if (native_new_exception && (new_exception_header != old_exception_header))1247{1248const __shim_type_info* excpType =1249static_cast<const __shim_type_info*>(new_exception_header->exceptionType);1250adjustedPtr =1251__getExceptionClass(&new_exception_header->unwindHeader) == kOurDependentExceptionClass ?1252((__cxa_dependent_exception*)new_exception_header)->primaryException :1253new_exception_header + 1;1254if (!exception_spec_can_catch(ttypeIndex, classInfo, ttypeEncoding,1255excpType, adjustedPtr,1256unwind_exception, base))1257{1258// We need to __cxa_end_catch, but for the old exception,1259// not the new one. This is a little tricky ...1260// Disguise new_exception_header as a rethrown exception, but1261// don't actually rethrow it. This means you can temporarily1262// end the catch clause enclosing new_exception_header without1263// __cxa_end_catch destroying new_exception_header.1264new_exception_header->handlerCount = -new_exception_header->handlerCount;1265globals->uncaughtExceptions += 1;1266// Call __cxa_end_catch for new_exception_header1267__cxa_end_catch();1268// Call __cxa_end_catch for old_exception_header1269__cxa_end_catch();1270// Renter this catch clause with new_exception_header1271__cxa_begin_catch(&new_exception_header->unwindHeader);1272// Rethrow new_exception_header1273throw;1274}1275}1276// Will a std::bad_exception be catchable by the exception spec at1277// ttypeIndex?1278// If no1279// throw std::bad_exception();1280const __shim_type_info* excpType =1281static_cast<const __shim_type_info*>(&typeid(std::bad_exception));1282std::bad_exception be;1283adjustedPtr = &be;1284if (!exception_spec_can_catch(ttypeIndex, classInfo, ttypeEncoding,1285excpType, adjustedPtr,1286unwind_exception, base))1287{1288// We need to __cxa_end_catch for both the old exception and the1289// new exception. Technically we should do it in that order.1290// But it is expedient to do it in the opposite order:1291// Call __cxa_end_catch for new_exception_header1292__cxa_end_catch();1293// Throw std::bad_exception will __cxa_end_catch for1294// old_exception_header1295throw be;1296}1297}1298}1299std::__terminate(t_handler);1300}13011302#if defined(_AIX)1303// Personality routine for EH using the range table. Make it an alias of1304// __gxx_personality_v0().1305_LIBCXXABI_FUNC_VIS _Unwind_Reason_Code __xlcxx_personality_v1(1306int version, _Unwind_Action actions, uint64_t exceptionClass,1307_Unwind_Exception* unwind_exception, _Unwind_Context* context)1308__attribute__((__alias__("__gxx_personality_v0")));1309#endif13101311} // extern "C"13121313} // __cxxabiv113141315#if defined(_AIX)1316// Include implementation of the personality and helper functions for the1317// state table based EH used by IBM legacy compilers xlC and xlclang++ on AIX.1318# include "aix_state_tab_eh.inc"1319#endif132013211322