Skip to content

Commit

Permalink
Apply all patches
Browse files Browse the repository at this point in the history
  • Loading branch information
am11 committed May 14, 2024
1 parent cd46bc1 commit a538057
Show file tree
Hide file tree
Showing 15 changed files with 506 additions and 236 deletions.
7 changes: 0 additions & 7 deletions src/native/external/llvm-libunwind.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,6 @@ set (LLVM_LIBUNWIND_SOURCES_BASE
src/libunwind.cpp
)

if(CLR_CMAKE_TARGET_APPLE)
set(LLVM_LIBUNWIND_SOURCES_BASE
${LLVM_LIBUNWIND_SOURCES_BASE}
src/Unwind_AppleExtras.cpp
)
endif()

set(LLVM_LIBUNWIND_ASM_SOURCES_BASE
src/UnwindRegistersRestore.S
src/UnwindRegistersSave.S
Expand Down
23 changes: 14 additions & 9 deletions src/native/external/llvm-libunwind/include/__libunwind_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
# endif
# if defined(__i386__)
# define _LIBUNWIND_TARGET_I386
# define _LIBUNWIND_CONTEXT_SIZE 8
# define _LIBUNWIND_CURSOR_SIZE 15
# define _LIBUNWIND_CONTEXT_SIZE 13
# define _LIBUNWIND_CURSOR_SIZE 19
# define _LIBUNWIND_HIGHEST_DWARF_REGISTER _LIBUNWIND_HIGHEST_DWARF_REGISTER_X86
# elif defined(__x86_64__)
# define _LIBUNWIND_TARGET_X86_64 1
Expand All @@ -54,8 +54,8 @@
# define _LIBUNWIND_CURSOR_SIZE 66
# endif
# else
# define _LIBUNWIND_CONTEXT_SIZE 21
# define _LIBUNWIND_CURSOR_SIZE 33
# define _LIBUNWIND_CONTEXT_SIZE 38
# define _LIBUNWIND_CURSOR_SIZE 50
# endif
# define _LIBUNWIND_HIGHEST_DWARF_REGISTER _LIBUNWIND_HIGHEST_DWARF_REGISTER_X86_64
# elif defined(__powerpc64__)
Expand All @@ -70,11 +70,11 @@
# define _LIBUNWIND_HIGHEST_DWARF_REGISTER _LIBUNWIND_HIGHEST_DWARF_REGISTER_PPC
# elif defined(__aarch64__)
# define _LIBUNWIND_TARGET_AARCH64 1
# define _LIBUNWIND_CONTEXT_SIZE 66
# define _LIBUNWIND_CONTEXT_SIZE 100
# if defined(__SEH__)
# define _LIBUNWIND_CURSOR_SIZE 164
# define _LIBUNWIND_CURSOR_SIZE 198
# else
# define _LIBUNWIND_CURSOR_SIZE 78
# define _LIBUNWIND_CURSOR_SIZE 112
# endif
# define _LIBUNWIND_HIGHEST_DWARF_REGISTER _LIBUNWIND_HIGHEST_DWARF_REGISTER_ARM64
# elif defined(__arm__)
Expand All @@ -86,8 +86,8 @@
# define _LIBUNWIND_CONTEXT_SIZE 61
# define _LIBUNWIND_CURSOR_SIZE 68
# else
# define _LIBUNWIND_CONTEXT_SIZE 42
# define _LIBUNWIND_CURSOR_SIZE 49
# define _LIBUNWIND_CONTEXT_SIZE 50
# define _LIBUNWIND_CURSOR_SIZE 57
# endif
# define _LIBUNWIND_HIGHEST_DWARF_REGISTER _LIBUNWIND_HIGHEST_DWARF_REGISTER_ARM
# elif defined(__or1k__)
Expand Down Expand Up @@ -175,6 +175,11 @@
#if __loongarch_grlen == 64
#define _LIBUNWIND_CONTEXT_SIZE 65
#define _LIBUNWIND_CURSOR_SIZE 77
#elif defined(HOST_WASM)
#define _LIBUNWIND_TARGET_WASM 1
// TODO: Determine the right values
#define _LIBUNWIND_CONTEXT_SIZE 0xbadf00d
#define _LIBUNWIND_CURSOR_SIZE 0xbadf00d
#else
#error "Unsupported LoongArch ABI"
#endif
Expand Down
24 changes: 22 additions & 2 deletions src/native/external/llvm-libunwind/include/libunwind.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,26 @@ struct unw_proc_info_t {
};
typedef struct unw_proc_info_t unw_proc_info_t;

enum unw_save_loc_type_t
{
UNW_SLT_NONE, /* register is not saved ("not an l-value") */
UNW_SLT_MEMORY, /* register has been saved in memory */
UNW_SLT_REG /* register has been saved in (another) register */
};
typedef enum unw_save_loc_type_t unw_save_loc_type_t;

struct unw_save_loc_t
{
unw_save_loc_type_t type;
union
{
unw_word_t addr; /* valid if type==UNW_SLT_MEMORY */
unw_regnum_t regnum; /* valid if type==UNW_SLT_REG */
}
u;
};
typedef struct unw_save_loc_t unw_save_loc_t;

#ifdef __cplusplus
extern "C" {
#endif
Expand All @@ -111,7 +131,7 @@ extern int unw_init_local(unw_cursor_t *, unw_context_t *) LIBUNWIND_AVAIL;
extern int unw_step(unw_cursor_t *) LIBUNWIND_AVAIL;
extern int unw_get_reg(unw_cursor_t *, unw_regnum_t, unw_word_t *) LIBUNWIND_AVAIL;
extern int unw_get_fpreg(unw_cursor_t *, unw_regnum_t, unw_fpreg_t *) LIBUNWIND_AVAIL;
extern int unw_set_reg(unw_cursor_t *, unw_regnum_t, unw_word_t) LIBUNWIND_AVAIL;
extern int unw_set_reg(unw_cursor_t *, unw_regnum_t, unw_word_t, unw_word_t *) LIBUNWIND_AVAIL;
extern int unw_set_fpreg(unw_cursor_t *, unw_regnum_t, unw_fpreg_t) LIBUNWIND_AVAIL;
extern int unw_resume(unw_cursor_t *) LIBUNWIND_AVAIL;

Expand All @@ -129,7 +149,7 @@ extern int unw_get_proc_info(unw_cursor_t *, unw_proc_info_t *) LIBUNWIND_AVAIL;
extern int unw_is_fpreg(unw_cursor_t *, unw_regnum_t) LIBUNWIND_AVAIL;
extern int unw_is_signal_frame(unw_cursor_t *) LIBUNWIND_AVAIL;
extern int unw_get_proc_name(unw_cursor_t *, char *, size_t, unw_word_t *) LIBUNWIND_AVAIL;
//extern int unw_get_save_loc(unw_cursor_t*, int, unw_save_loc_t*);
extern int unw_get_save_loc(unw_cursor_t*, int, unw_save_loc_t*) LIBUNWIND_AVAIL;

extern unw_addr_space_t unw_local_addr_space;

Expand Down
8 changes: 4 additions & 4 deletions src/native/external/llvm-libunwind/include/unwind_arm_ehabi.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ _Unwind_VRS_Get(_Unwind_Context *context, _Unwind_VRS_RegClass regclass,
extern _Unwind_VRS_Result
_Unwind_VRS_Set(_Unwind_Context *context, _Unwind_VRS_RegClass regclass,
uint32_t regno, _Unwind_VRS_DataRepresentation representation,
void *valuep);
void *valuep, uintptr_t *pos);

extern _Unwind_VRS_Result
_Unwind_VRS_Pop(_Unwind_Context *context, _Unwind_VRS_RegClass regclass,
Expand Down Expand Up @@ -147,8 +147,8 @@ uintptr_t _Unwind_GetGR(struct _Unwind_Context *context, int index) {

_LIBUNWIND_EXPORT_UNWIND_LEVEL1
void _Unwind_SetGR(struct _Unwind_Context *context, int index,
uintptr_t value) {
_Unwind_VRS_Set(context, _UVRSC_CORE, (uint32_t)index, _UVRSD_UINT32, &value);
uintptr_t value, uintptr_t *pos) {
_Unwind_VRS_Set(context, _UVRSC_CORE, (uint32_t)index, _UVRSD_UINT32, &value, pos);
}

_LIBUNWIND_EXPORT_UNWIND_LEVEL1
Expand All @@ -160,7 +160,7 @@ uintptr_t _Unwind_GetIP(struct _Unwind_Context *context) {
_LIBUNWIND_EXPORT_UNWIND_LEVEL1
void _Unwind_SetIP(struct _Unwind_Context *context, uintptr_t value) {
uintptr_t thumb_bit = _Unwind_GetGR(context, 15) & ((uintptr_t)0x1);
_Unwind_SetGR(context, 15, value | thumb_bit);
_Unwind_SetGR(context, 15, value | thumb_bit, NULL);
}

#ifdef __cplusplus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ extern void _Unwind_DeleteException(_Unwind_Exception *exception_object);

extern uintptr_t _Unwind_GetGR(struct _Unwind_Context *context, int index);
extern void _Unwind_SetGR(struct _Unwind_Context *context, int index,
uintptr_t new_value);
uintptr_t new_value, uintptr_t *pos);
extern uintptr_t _Unwind_GetIP(struct _Unwind_Context *context);
extern void _Unwind_SetIP(struct _Unwind_Context *, uintptr_t new_value);

Expand Down
7 changes: 2 additions & 5 deletions src/native/external/llvm-libunwind/src/AddressSpace.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "dwarf2.h"
#include "EHHeaderParser.hpp"
#include "Registers.hpp"
#include "libunwind_ext.h"

#ifndef _LIBUNWIND_USE_DLADDR
#if !(defined(_LIBUNWIND_IS_BAREMETAL) || defined(_WIN32) || defined(_AIX))
Expand Down Expand Up @@ -603,11 +604,7 @@ inline bool LocalAddressSpace::findUnwindSections(pint_t targetAddr,
// `_dl_find_object`. Use _LIBUNWIND_SUPPORT_DWARF_INDEX, because libunwind
// support for _dl_find_object on other unwind formats is not implemented,
// yet.
#if defined(DLFO_STRUCT_HAS_EH_DBASE) & defined(_LIBUNWIND_SUPPORT_DWARF_INDEX)
// We expect `_dl_find_object` to return PT_GNU_EH_FRAME.
#if DLFO_EH_SEGMENT_TYPE != PT_GNU_EH_FRAME
#error _dl_find_object retrieves an unexpected section type
#endif
#if defined(DLFO_STRUCT_HAS_EH_DBASE) && defined(_LIBUNWIND_SUPPORT_DWARF_INDEX) && DLFO_EH_SEGMENT_TYPE == PT_GNU_EH_FRAME
// We look-up `dl_find_object` dynamically at runtime to ensure backwards
// compatibility with earlier version of glibc not yet providing it. On older
// systems, we gracefully fallback to `dl_iterate_phdr`. Cache the pointer
Expand Down
Loading

0 comments on commit a538057

Please sign in to comment.