diff --git a/repos/base/lib/mk/cxx.mk b/repos/base/lib/mk/cxx.mk index 3ec45cff1..4d86d51ea 100644 --- a/repos/base/lib/mk/cxx.mk +++ b/repos/base/lib/mk/cxx.mk @@ -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 STDINC = yes 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 @@ -43,10 +43,11 @@ LIBCXX_GCC = $(shell $(CUSTOM_CXX_LIB) $(CC_MARCH) -print-file-name=libsupc++.a) # Dummy target used by the build system # SRC_S = supc++.o +SRC_C = unwind.o CXX_SRC = $(sort $(CXX_SRC_CC)) CXX_OBJECTS = $(addsuffix .o,$(basename $(CXX_SRC))) 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' diff --git a/repos/base/src/base/cxx/unwind.c b/repos/base/src/base/cxx/unwind.c new file mode 100644 index 000000000..912270b39 --- /dev/null +++ b/repos/base/src/base/cxx/unwind.c @@ -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__ */ diff --git a/repos/base/src/base/cxx/unwind.cc b/repos/base/src/base/cxx/unwind.cc deleted file mode 100644 index ca1170cba..000000000 --- a/repos/base/src/base/cxx/unwind.cc +++ /dev/null @@ -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 -}