Add fixes to libunwind (#1069)

This commit is contained in:
Trung Nguyen 2024-01-08 23:31:13 +07:00 committed by GitHub
parent cafea9a0a5
commit 94bab1618d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 7 additions and 78 deletions

View file

@ -441,6 +441,7 @@ COSMOPOLITAN_OBJECTS = \
LIBC_TIME \
THIRD_PARTY_MUSL \
THIRD_PARTY_ZLIB_GZ \
THIRD_PARTY_LIBUNWIND \
LIBC_STDIO \
THIRD_PARTY_GDTOA \
THIRD_PARTY_REGEX \

View file

@ -1,37 +0,0 @@
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
vi: set et ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi
Copyright 2022 Justine Alexandra Roberts Tunney
Permission to use, copy, modify, and/or distribute this software for
any purpose with or without fee is hereby granted, provided that the
above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/runtime/unwind.h"
// temporary stubs for libunwind
uintptr_t _Unwind_GetCFA(struct _Unwind_Context *ctx) {
return 0;
}
uintptr_t _Unwind_GetIP(struct _Unwind_Context *ctx) {
return 0;
}
_Unwind_Reason_Code _Unwind_Backtrace(_Unwind_Trace_Fn fn, void *arg) {
return _URC_NORMAL_STOP;
}
void *_Unwind_FindEnclosingFunction(void *arg) {
return NULL;
}

View file

@ -1,40 +0,0 @@
#ifndef COSMOPOLITAN_LIBC_RUNTIME_UNWIND_H_
#define COSMOPOLITAN_LIBC_RUNTIME_UNWIND_H_
#define UNW_TDEP_CURSOR_LEN 127
COSMOPOLITAN_C_START_
typedef enum {
_URC_NO_REASON = 0,
_URC_FOREIGN_EXCEPTION_CAUGHT = 1,
_URC_FATAL_PHASE2_ERROR = 2,
_URC_FATAL_PHASE1_ERROR = 3,
_URC_NORMAL_STOP = 4,
_URC_END_OF_STACK = 5,
_URC_HANDLER_FOUND = 6,
_URC_INSTALL_CONTEXT = 7,
_URC_CONTINUE_UNWIND = 8
} _Unwind_Reason_Code;
typedef uint64_t unw_word_t;
typedef struct unw_cursor {
unw_word_t opaque[UNW_TDEP_CURSOR_LEN];
} unw_cursor_t;
struct _Unwind_Context {
unw_cursor_t cursor;
int end_of_stack;
};
typedef _Unwind_Reason_Code (*_Unwind_Trace_Fn)(struct _Unwind_Context *,
void *);
uintptr_t _Unwind_GetCFA(struct _Unwind_Context *);
uintptr_t _Unwind_GetIP(struct _Unwind_Context *);
_Unwind_Reason_Code _Unwind_Backtrace(_Unwind_Trace_Fn, void *);
void *_Unwind_FindEnclosingFunction(void *);
COSMOPOLITAN_C_END_
#endif /* COSMOPOLITAN_LIBC_RUNTIME_UNWIND_H_ */

View file

@ -11,3 +11,6 @@ ORIGIN
Author: Tobias Hieta <tobias@hieta.se>
Date: Tue, 28 Nov 2023 09:52:28 +0100
LOCAL CHANGES
- Fixed `_Unwind_FunctionContext` struct to be ABI-compatible with code
generated by GCC.

View file

@ -28,6 +28,8 @@
#if defined(_LIBUNWIND_BUILD_SJLJ_APIS)
typedef uintptr_t _Unwind_Word __attribute__((__mode__(__unwind_word__)));
struct _Unwind_FunctionContext {
// next function in stack of handlers
struct _Unwind_FunctionContext *prev;
@ -47,7 +49,7 @@ struct _Unwind_FunctionContext {
uint32_t resumeLocation;
// set by personality handler to be parameters passed to landing pad function
uint32_t resumeParameters[4];
_Unwind_Word resumeParameters[4];
#endif
// set by calling function before registering