mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-02-07 06:53:33 +00:00
Restore MODE=dbg support
We recently broke MODE=dbg support when we added C++ exception support. This change adds the missing UBSAN interfaces, needed to get it working again. Some of the ASAN checking in the SJLJ guts needed to be disabled since I doubt anyone's combined the two features until now.
This commit is contained in:
parent
f27808c4d2
commit
c1e18e7903
5 changed files with 34 additions and 38 deletions
|
@ -112,6 +112,13 @@ struct UbsanOverflowData {
|
|||
struct UbsanTypeDescriptor *type;
|
||||
};
|
||||
|
||||
struct UbsanDynamicTypeCacheMissData {
|
||||
struct UbsanSourceLocation location;
|
||||
struct UbsanTypeDescriptor *type;
|
||||
void *TypeInfo;
|
||||
unsigned char TypeCheckKind;
|
||||
};
|
||||
|
||||
struct UbsanFloatCastOverflowData {
|
||||
#if __GNUC__ + 0 >= 6
|
||||
struct UbsanSourceLocation location;
|
||||
|
@ -145,6 +152,8 @@ upcast of\0\
|
|||
cast to virtual base of\0\
|
||||
\0";
|
||||
|
||||
uintptr_t __ubsan_vptr_type_cache[128];
|
||||
|
||||
static int __ubsan_bits(struct UbsanTypeDescriptor *t) {
|
||||
return 1 << (t->info >> 1);
|
||||
}
|
||||
|
@ -439,15 +448,22 @@ void __ubsan_handle_divrem_overflow_abort(
|
|||
__ubsan_handle_divrem_overflow(loc);
|
||||
}
|
||||
|
||||
static bool HandleDynamicTypeCacheMiss(
|
||||
struct UbsanDynamicTypeCacheMissData *data, uintptr_t ptr, uintptr_t hash) {
|
||||
return false; // TODO: implement me
|
||||
}
|
||||
|
||||
void __ubsan_handle_dynamic_type_cache_miss(
|
||||
const struct UbsanSourceLocation *loc) {
|
||||
__ubsan_abort(loc, "dynamic type cache miss")();
|
||||
__ubsan_unreachable();
|
||||
struct UbsanDynamicTypeCacheMissData *data, uintptr_t ptr, uintptr_t hash) {
|
||||
HandleDynamicTypeCacheMiss(data, ptr, hash);
|
||||
}
|
||||
|
||||
void __ubsan_handle_dynamic_type_cache_miss_abort(
|
||||
const struct UbsanSourceLocation *loc) {
|
||||
__ubsan_handle_dynamic_type_cache_miss(loc);
|
||||
struct UbsanDynamicTypeCacheMissData *data, uintptr_t ptr, uintptr_t hash) {
|
||||
if (HandleDynamicTypeCacheMiss(data, ptr, hash)) {
|
||||
__ubsan_abort(&data->location, "dynamic type cache miss")();
|
||||
__ubsan_unreachable();
|
||||
}
|
||||
}
|
||||
|
||||
void __ubsan_handle_function_type_mismatch(
|
||||
|
|
8
third_party/libcxxabi/cxa_personality.cc
vendored
8
third_party/libcxxabi/cxa_personality.cc
vendored
|
@ -202,7 +202,7 @@ enum
|
|||
/// @link http://dwarfstd.org/Dwarf4.pdf @unlink
|
||||
/// @param data reference variable holding memory pointer to decode from
|
||||
/// @returns decoded value
|
||||
static
|
||||
static dontasan
|
||||
uintptr_t
|
||||
readULEB128(const uint8_t** data)
|
||||
{
|
||||
|
@ -225,7 +225,7 @@ readULEB128(const uint8_t** data)
|
|||
/// @link http://dwarfstd.org/Dwarf4.pdf @unlink
|
||||
/// @param data reference variable holding memory pointer to decode from
|
||||
/// @returns decoded value
|
||||
static
|
||||
static dontasan
|
||||
intptr_t
|
||||
readSLEB128(const uint8_t** data)
|
||||
{
|
||||
|
@ -542,7 +542,7 @@ struct scan_results
|
|||
|
||||
} // unnamed namespace
|
||||
|
||||
static
|
||||
static dontasan
|
||||
void
|
||||
set_registers(_Unwind_Exception* unwind_exception, _Unwind_Context* context,
|
||||
const scan_results& results)
|
||||
|
@ -581,6 +581,7 @@ set_registers(_Unwind_Exception* unwind_exception, _Unwind_Context* context,
|
|||
_UA_CLEANUP_PHASE && !_UA_HANDLER_FRAME
|
||||
*/
|
||||
|
||||
dontasan
|
||||
static void scan_eh_tab(scan_results &results, _Unwind_Action actions,
|
||||
bool native_exception,
|
||||
_Unwind_Exception *unwind_exception,
|
||||
|
@ -911,6 +912,7 @@ static _Unwind_Reason_Code __gxx_personality_imp
|
|||
#else
|
||||
_LIBCXXABI_FUNC_VIS _Unwind_Reason_Code
|
||||
#ifdef __USING_SJLJ_EXCEPTIONS__
|
||||
dontasan
|
||||
__gxx_personality_sj0
|
||||
#elif defined(__MVS__)
|
||||
__zos_cxx_personality_v2
|
||||
|
|
7
third_party/libunwind/README.cosmo
vendored
7
third_party/libunwind/README.cosmo
vendored
|
@ -12,5 +12,8 @@ ORIGIN
|
|||
Date: Tue, 28 Nov 2023 09:52:28 +0100
|
||||
|
||||
LOCAL CHANGES
|
||||
- Fixed `_Unwind_FunctionContext` struct to be ABI-compatible with code
|
||||
generated by GCC.
|
||||
|
||||
- Fixed `_Unwind_FunctionContext` struct to be ABI-compatible with
|
||||
code generated by GCC.
|
||||
|
||||
- Added `dontasan` annotations to functions that raised ASAN errors.
|
||||
|
|
5
third_party/libunwind/Unwind-sjlj.c
vendored
5
third_party/libunwind/Unwind-sjlj.c
vendored
|
@ -105,7 +105,7 @@ __Unwind_SjLj_SetTopOfFunctionStack(struct _Unwind_FunctionContext *fc) {
|
|||
|
||||
|
||||
/// Called at start of each function that catches exceptions
|
||||
_LIBUNWIND_EXPORT void
|
||||
_LIBUNWIND_EXPORT void dontasan
|
||||
_Unwind_SjLj_Register(struct _Unwind_FunctionContext *fc) {
|
||||
fc->prev = __Unwind_SjLj_GetTopOfFunctionStack();
|
||||
__Unwind_SjLj_SetTopOfFunctionStack(fc);
|
||||
|
@ -113,7 +113,7 @@ _Unwind_SjLj_Register(struct _Unwind_FunctionContext *fc) {
|
|||
|
||||
|
||||
/// Called at end of each function that catches exceptions
|
||||
_LIBUNWIND_EXPORT void
|
||||
_LIBUNWIND_EXPORT void dontasan
|
||||
_Unwind_SjLj_Unregister(struct _Unwind_FunctionContext *fc) {
|
||||
__Unwind_SjLj_SetTopOfFunctionStack(fc->prev);
|
||||
}
|
||||
|
@ -426,6 +426,7 @@ _LIBUNWIND_EXPORT uintptr_t _Unwind_GetGR(struct _Unwind_Context *context,
|
|||
|
||||
|
||||
/// Called by personality handler during phase 2 to alter register values.
|
||||
dontasan
|
||||
_LIBUNWIND_EXPORT void _Unwind_SetGR(struct _Unwind_Context *context, int index,
|
||||
uintptr_t new_value) {
|
||||
_LIBUNWIND_TRACE_API("_Unwind_SetGR(context=%p, reg=%d, value=0x%" PRIuPTR
|
||||
|
|
26
third_party/nsync/README.md
vendored
26
third_party/nsync/README.md
vendored
|
@ -1,26 +0,0 @@
|
|||
# *NSYNC
|
||||
|
||||
*NSYNC is a library providing scalable synchronization primitives. The
|
||||
following packages are provided:
|
||||
|
||||
- `THIRD_PARTY_NSYNC` has `nsync_mu` which doesn't depend on malloc().
|
||||
- `THIRD_PARTY_NSYNC_MEM` has the rest of *NSYNC, e.g. `nsync_cv`.
|
||||
|
||||
The origin of this code is here:
|
||||
|
||||
git@github.com:google/nsync
|
||||
ac5489682760393fe21bd2a8e038b528442412a7 (1.25.0)
|
||||
Author: Mike Burrows <m3b@google.com>
|
||||
Date: Wed Jun 1 16:47:52 2022 -0700
|
||||
|
||||
NSYNC uses the Apache 2.0 license. We made the following local changes:
|
||||
|
||||
- Write custom `nsync_malloc_()` so `malloc()` can use *NSYNC.
|
||||
|
||||
- Rewrite `futex()` wrapper to support old Linux kernels and OpenBSD.
|
||||
|
||||
- Normalize sources to Cosmopolitan style conventions; *NSYNC upstream
|
||||
supports dozens of compilers and operating systems, at compile-time.
|
||||
Since Cosmo solves portability at runtime instead, most of the build
|
||||
config toil has been removed, in order to help the NSYNC source code
|
||||
be more readable and hackable.
|
Loading…
Reference in a new issue