mirror of
https://github.com/genodelabs/genode.git
synced 2025-05-09 20:12:57 +00:00
cxx: Simplify C++ exception wrapper functions
The wrapper functions (e.g., 'Unwind_*' and friends) now have the same signature as the original function in 'libgcc', reside in a separate C file which is archived to cxx.lib.a. In supc++.o we prefix the wrapped functions with '_cxx_'. This also enables support for riscv. related to #1880
This commit is contained in:
parent
bfe5208e0e
commit
d424134073
@ -1,9 +1,9 @@
|
|||||||
CXX_SRC_CC += misc.cc new_delete.cc malloc_free.cc exception.cc guard.cc unwind.cc
|
CXX_SRC_CC += misc.cc new_delete.cc malloc_free.cc exception.cc guard.cc
|
||||||
|
|
||||||
# We need the libsupc++ include directory
|
# We need the libsupc++ include directory
|
||||||
STDINC = yes
|
STDINC = yes
|
||||||
|
|
||||||
vpath %.cc $(BASE_DIR)/src/base/cxx
|
vpath %.cc $(BASE_DIR)/src/base/cxx
|
||||||
|
vpath %.c $(BASE_DIR)/src/base/cxx
|
||||||
|
|
||||||
#
|
#
|
||||||
# Here we define all symbols we want to hide in libsupc++ and libgcc_eh
|
# Here we define all symbols we want to hide in libsupc++ and libgcc_eh
|
||||||
@ -43,10 +43,11 @@ LIBCXX_GCC = $(shell $(CUSTOM_CXX_LIB) $(CC_MARCH) -print-file-name=libsupc++.a)
|
|||||||
# Dummy target used by the build system
|
# Dummy target used by the build system
|
||||||
#
|
#
|
||||||
SRC_S = supc++.o
|
SRC_S = supc++.o
|
||||||
|
SRC_C = unwind.o
|
||||||
CXX_SRC = $(sort $(CXX_SRC_CC))
|
CXX_SRC = $(sort $(CXX_SRC_CC))
|
||||||
CXX_OBJECTS = $(addsuffix .o,$(basename $(CXX_SRC)))
|
CXX_OBJECTS = $(addsuffix .o,$(basename $(CXX_SRC)))
|
||||||
LOCAL_SYMBOLS = $(patsubst %,--localize-symbol=%,$(LIBC_SYMBOLS))
|
LOCAL_SYMBOLS = $(patsubst %,--localize-symbol=%,$(LIBC_SYMBOLS))
|
||||||
REDEF_SYMBOLS = $(foreach S, $(EH_SYMBOLS), --redefine-sym $(S)=_cxx_$(S) --redefine-sym __cxx_$(S)=$(S))
|
REDEF_SYMBOLS = $(foreach S, $(EH_SYMBOLS), --redefine-sym $(S)=_cxx_$(S))
|
||||||
|
|
||||||
#
|
#
|
||||||
# Prevent symbols of the gcc support libs from being discarded during 'ld -r'
|
# Prevent symbols of the gcc support libs from being discarded during 'ld -r'
|
||||||
|
48
repos/base/src/base/cxx/unwind.c
Normal file
48
repos/base/src/base/cxx/unwind.c
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
* \brief Wrapper for symbols required by libgcc_eh's exception handling
|
||||||
|
* \author Sebastian Sumpf
|
||||||
|
* \date 2015-09-04
|
||||||
|
*
|
||||||
|
* The wrapper always calls a function with prefix '_cxx'. In 'cxx.mk' we prefix
|
||||||
|
* the wrapped functions with '_cxx'. This whole procedure became necessary
|
||||||
|
* since the wrapped symbols are marked 'GLOBAL', 'HIDDEN' in libgcc_eh.a and
|
||||||
|
* thus ligcc_eh had to be linked to *all* binaries. In shared libaries this
|
||||||
|
* became unfeasible since libgcc_eh uses global data which might not be
|
||||||
|
* initialized during cross-library interaction. The clean way to go would be
|
||||||
|
* to link libgcc_s.so to DSOs and dynamic binaries, unfortunally ligcc_s
|
||||||
|
* requires libc6 in the current Genode tool chain.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2011-2013 Genode Labs GmbH
|
||||||
|
*
|
||||||
|
* This file is part of the Genode OS framework, which is distributed
|
||||||
|
* under the terms of the GNU General Public License version 2.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Unwind function found in all binaries */
|
||||||
|
void _cxx__Unwind_Resume(void *exc) __attribute__((weak));
|
||||||
|
void _Unwind_Resume(void *exc) {
|
||||||
|
_cxx__Unwind_Resume(exc); }
|
||||||
|
|
||||||
|
void _cxx__Unwind_DeleteException(void *exc) __attribute__((weak));
|
||||||
|
void _Unwind_DeleteException(void *exc) {
|
||||||
|
_cxx__Unwind_DeleteException(exc); }
|
||||||
|
|
||||||
|
/* Special ARM-EABI personality functions */
|
||||||
|
#ifdef __ARM_EABI__
|
||||||
|
|
||||||
|
int _cxx___aeabi_unwind_cpp_pr0(int state, void *block, void *context) __attribute__((weak));
|
||||||
|
int __aeabi_unwind_cpp_pr0(int state, void *block, void *context) {
|
||||||
|
return _cxx___aeabi_unwind_cpp_pr0(state, block, context); }
|
||||||
|
|
||||||
|
int _cxx___aeabi_unwind_cpp_pr1(int state, void *block, void *context) __attribute__((weak));
|
||||||
|
int __aeabi_unwind_cpp_pr1(int state, void *block, void *context) {
|
||||||
|
return _cxx___aeabi_unwind_cpp_pr1(state, block, context); }
|
||||||
|
|
||||||
|
/* Unwind functions found in some binaries */
|
||||||
|
void _cxx__Unwind_Complete(void *exc) __attribute__((weak));
|
||||||
|
void _Unwind_Complete(void *exc) {
|
||||||
|
_cxx__Unwind_Complete(exc); }
|
||||||
|
|
||||||
|
#endif /* __ARM_EABI__ */
|
@ -1,53 +0,0 @@
|
|||||||
/*
|
|
||||||
* \brief Wrapper for symbols required by libgcc_eh's exception handling
|
|
||||||
* \author Sebastian Sumpf
|
|
||||||
* \date 2011-07-20
|
|
||||||
*
|
|
||||||
* The actual wrapper function is prefixed with '__cxx', the wrapper always
|
|
||||||
* calls a function with prefix '_cxx' (note the missing '_'). In 'cxx.mk'
|
|
||||||
* we remove the leading '__cxx' from the wrapper which than becomes the symbol
|
|
||||||
* of the wrapped function, in turn the wrapped function is prefixed with '_cxx'.
|
|
||||||
* This whole procedure became necessary since the wrapped symbols are marked
|
|
||||||
* 'GLOBAL', 'HIDDEN' in libgcc_eh.a and thus ligcc_eh had to be linked to *all*
|
|
||||||
* binaries. In shared libaries this became unfeasible since libgcc_eh uses
|
|
||||||
* global data which might not be initialized during cross-library interaction.
|
|
||||||
* The clean way to go would be to link libgcc_s.so to DSOs and dynamic
|
|
||||||
* binaries, unfortunally ligcc_s requires libc6 in the current Genode tool
|
|
||||||
* chain.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copyright (C) 2011-2013 Genode Labs GmbH
|
|
||||||
*
|
|
||||||
* This file is part of the Genode OS framework, which is distributed
|
|
||||||
* under the terms of the GNU General Public License version 2.
|
|
||||||
*/
|
|
||||||
|
|
||||||
extern "C" {
|
|
||||||
|
|
||||||
/* Unwind function found in all binaries */
|
|
||||||
void _cxx__Unwind_Resume(void *exc) __attribute__((weak));
|
|
||||||
void __cxx__Unwind_Resume(void *exc) {
|
|
||||||
_cxx__Unwind_Resume(exc); }
|
|
||||||
|
|
||||||
void _cxx__Unwind_DeleteException(void *exc) __attribute__((weak));
|
|
||||||
void __cxx__Unwind_DeleteException(void *exc) {
|
|
||||||
_cxx__Unwind_DeleteException(exc); }
|
|
||||||
|
|
||||||
/* Special ARM-EABI personality functions */
|
|
||||||
#ifdef __ARM_EABI__
|
|
||||||
|
|
||||||
int _cxx___aeabi_unwind_cpp_pr0(int state, void *block, void *context) __attribute__((weak));
|
|
||||||
int __cxx___aeabi_unwind_cpp_pr0(int state, void *block, void *context) {
|
|
||||||
return _cxx___aeabi_unwind_cpp_pr0(state, block, context); }
|
|
||||||
|
|
||||||
int _cxx___aeabi_unwind_cpp_pr1(int state, void *block, void *context) __attribute__((weak));
|
|
||||||
int __cxx___aeabi_unwind_cpp_pr1(int state, void *block, void *context) {
|
|
||||||
return _cxx___aeabi_unwind_cpp_pr1(state, block, context); }
|
|
||||||
|
|
||||||
/* Unwind functions found in some binaries */
|
|
||||||
void _cxx__Unwind_Complete(void *exc) __attribute__((weak));
|
|
||||||
void __cxx__Unwind_Complete(void *exc) {
|
|
||||||
_cxx__Unwind_Complete(exc); }
|
|
||||||
#endif
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user