[libcxx-commits] [libcxxabi] 7f0244a - [libc++abi] NFC: adding a new parameter base to functions for calculating addresses with relative encodings
Xing Xue via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Jun 10 07:46:29 PDT 2021
Author: Xing Xue
Date: 2021-06-10T10:45:50-04:00
New Revision: 7f0244afa828e0ef725a3f951304577090495713
URL: https://github.com/llvm/llvm-project/commit/7f0244afa828e0ef725a3f951304577090495713
DIFF: https://github.com/llvm/llvm-project/commit/7f0244afa828e0ef725a3f951304577090495713.diff
LOG: [libc++abi] NFC: adding a new parameter base to functions for calculating addresses with relative encodings
Summary:
This NFC patch adds a new parameter base to functions invoked by scan_eh_tab() for calculating the address of the encoding with a relative value. base defaults to 0. This is in preparation for the AIX implementation which uses the DW_EH_PE_datarel encoding.
Reviewed by: MaskRay, sfertile, compnerd, libc++abi
Differential Revision: https://reviews.llvm.org/D101545
Added:
Modified:
libcxxabi/src/cxa_personality.cpp
Removed:
################################################################################
diff --git a/libcxxabi/src/cxa_personality.cpp b/libcxxabi/src/cxa_personality.cpp
index cc0208c9b136..1a656f2229ed 100644
--- a/libcxxabi/src/cxa_personality.cpp
+++ b/libcxxabi/src/cxa_personality.cpp
@@ -241,10 +241,11 @@ readSLEB128(const uint8_t** data)
/// @link http://dwarfstd.org/Dwarf3.pdf @unlink
/// @param data reference variable holding memory pointer to decode from
/// @param encoding dwarf encoding type
+/// @param base for adding relative offset, default to 0
/// @returns decoded value
static
uintptr_t
-readEncodedPointer(const uint8_t** data, uint8_t encoding)
+readEncodedPointer(const uint8_t** data, uint8_t encoding, uintptr_t base = 0)
{
uintptr_t result = 0;
if (encoding == DW_EH_PE_omit)
@@ -348,7 +349,7 @@ static const void* read_target2_value(const void* ptr)
static const __shim_type_info*
get_shim_type_info(uint64_t ttypeIndex, const uint8_t* classInfo,
uint8_t ttypeEncoding, bool native_exception,
- _Unwind_Exception* unwind_exception)
+ _Unwind_Exception* unwind_exception, uintptr_t base = 0)
{
if (classInfo == 0)
{
@@ -371,7 +372,7 @@ static
const __shim_type_info*
get_shim_type_info(uint64_t ttypeIndex, const uint8_t* classInfo,
uint8_t ttypeEncoding, bool native_exception,
- _Unwind_Exception* unwind_exception)
+ _Unwind_Exception* unwind_exception, uintptr_t base = 0)
{
if (classInfo == 0)
{
@@ -400,7 +401,8 @@ get_shim_type_info(uint64_t ttypeIndex, const uint8_t* classInfo,
call_terminate(native_exception, unwind_exception);
}
classInfo -= ttypeIndex;
- return (const __shim_type_info*)readEncodedPointer(&classInfo, ttypeEncoding);
+ return (const __shim_type_info*)readEncodedPointer(&classInfo,
+ ttypeEncoding, base);
}
#endif // !defined(_LIBCXXABI_ARM_EHABI)
@@ -418,7 +420,8 @@ static
bool
exception_spec_can_catch(int64_t specIndex, const uint8_t* classInfo,
uint8_t ttypeEncoding, const __shim_type_info* excpType,
- void* adjustedPtr, _Unwind_Exception* unwind_exception)
+ void* adjustedPtr, _Unwind_Exception* unwind_exception,
+ uintptr_t base = 0)
{
if (classInfo == 0)
{
@@ -463,7 +466,8 @@ static
bool
exception_spec_can_catch(int64_t specIndex, const uint8_t* classInfo,
uint8_t ttypeEncoding, const __shim_type_info* excpType,
- void* adjustedPtr, _Unwind_Exception* unwind_exception)
+ void* adjustedPtr, _Unwind_Exception* unwind_exception,
+ uintptr_t base = 0)
{
if (classInfo == 0)
{
@@ -485,7 +489,8 @@ exception_spec_can_catch(int64_t specIndex, const uint8_t* classInfo,
classInfo,
ttypeEncoding,
true,
- unwind_exception);
+ unwind_exception,
+ base);
void* tempPtr = adjustedPtr;
if (catchType->can_catch(excpType, tempPtr))
return false;
@@ -610,6 +615,7 @@ static void scan_eh_tab(scan_results &results, _Unwind_Action actions,
return;
}
results.languageSpecificData = lsda;
+ uintptr_t base = 0;
// Get the current instruction pointer and offset it before next
// instruction in the current frame which threw the exception.
uintptr_t ip = _Unwind_GetIP(context) - 1;
@@ -711,7 +717,8 @@ static void scan_eh_tab(scan_results &results, _Unwind_Action actions,
const __shim_type_info* catchType =
get_shim_type_info(static_cast<uint64_t>(ttypeIndex),
classInfo, ttypeEncoding,
- native_exception, unwind_exception);
+ native_exception, unwind_exception,
+ base);
if (catchType == 0)
{
// Found catch (...) catches everything, including
@@ -772,7 +779,8 @@ static void scan_eh_tab(scan_results &results, _Unwind_Action actions,
}
if (exception_spec_can_catch(ttypeIndex, classInfo,
ttypeEncoding, excpType,
- adjustedPtr, unwind_exception))
+ adjustedPtr,
+ unwind_exception, base))
{
// Native exception caught by exception
// specification.
@@ -1114,6 +1122,8 @@ __cxa_call_unexpected(void* arg)
__cxa_exception* old_exception_header = 0;
int64_t ttypeIndex;
const uint8_t* lsda;
+ uintptr_t base = 0;
+
if (native_old_exception)
{
old_exception_header = (__cxa_exception*)(unwind_exception+1) - 1;
@@ -1181,7 +1191,8 @@ __cxa_call_unexpected(void* arg)
((__cxa_dependent_exception*)new_exception_header)->primaryException :
new_exception_header + 1;
if (!exception_spec_can_catch(ttypeIndex, classInfo, ttypeEncoding,
- excpType, adjustedPtr, unwind_exception))
+ excpType, adjustedPtr,
+ unwind_exception, base))
{
// We need to __cxa_end_catch, but for the old exception,
// not the new one. This is a little tricky ...
@@ -1210,7 +1221,8 @@ __cxa_call_unexpected(void* arg)
std::bad_exception be;
adjustedPtr = &be;
if (!exception_spec_can_catch(ttypeIndex, classInfo, ttypeEncoding,
- excpType, adjustedPtr, unwind_exception))
+ excpType, adjustedPtr,
+ unwind_exception, base))
{
// We need to __cxa_end_catch for both the old exception and the
// new exception. Technically we should do it in that order.
More information about the libcxx-commits
mailing list