Skip to content

Commit 67b8b05

Browse files
authored
🐛 (patch) Wrap _Unwind_Resume (#78)
When using LTO, the compiler may emit a `_Unwind_Resume` call rather than a `__cxa_end_cleanup` at the end of a landing pad. Calling GCC's unwinder while the estell unwinder is running will be UB. This wraps that API to call our `__cxa_end_cleanup`. The pointer to the current exception object passed to _Unwind_Resume, is ignored.
1 parent 7cb201d commit 67b8b05

File tree

9 files changed

+28
-34781
lines changed

9 files changed

+28
-34781
lines changed

conanfile.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,33 +112,38 @@ def package_info(self):
112112
self.cpp_info.set_property("cmake_target_name", "libhal::exceptions")
113113
lib_path = os.path.join(self.package_folder,
114114
'lib', 'liblibhal-exceptions.a')
115-
115+
using_wrap = False
116116
if self.options.runtime == "estell":
117+
using_wrap = True
117118
self.cpp_info.exelinkflags.extend([
118119
"-fexceptions",
119120
"-Wl,--wrap=__cxa_throw",
120121
"-Wl,--wrap=__cxa_rethrow",
121122
"-Wl,--wrap=__cxa_end_catch",
122123
"-Wl,--wrap=__cxa_begin_catch",
123124
"-Wl,--wrap=__cxa_end_cleanup",
125+
"-Wl,--wrap=_Unwind_Resume",
124126
"-Wl,--wrap=__gnu_unwind_pr_common",
125127
"-Wl,--wrap=__aeabi_unwind_cpp_pr0",
128+
"-Wl,--wrap=__aeabi_unwind_cpp_pr1",
129+
"-Wl,--wrap=__aeabi_unwind_cpp_pr2",
126130
"-Wl,--wrap=_sig_func",
127131
"-Wl,--wrap=__gxx_personality_v0",
128132
"-Wl,--wrap=deregister_tm_clones",
129133
"-Wl,--wrap=register_tm_clones",
130-
# Ensure that all symbols are added to the linker's symbol table
131-
"-Wl,--whole-archive",
132-
lib_path,
133-
"-Wl,--no-whole-archive",
134134
])
135135

136136
# Keep this for now, will update this for the runtime select
137137
if self._is_arm_cortex:
138+
using_wrap = True
138139
self.cpp_info.exelinkflags.extend([
139140
"-Wl,--wrap=__cxa_allocate_exception",
140141
"-Wl,--wrap=__cxa_free_exception",
141142
"-Wl,--wrap=__cxa_call_unexpected",
143+
])
144+
145+
if using_wrap:
146+
self.cpp_info.exelinkflags.extend([
142147
# Ensure that all symbols are added to the linker's symbol table
143148
"-Wl,--whole-archive",
144149
lib_path,

demos/CMakeLists.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --save-temps")
2121
libhal_build_demos(
2222
DEMOS
2323
single_level
24-
multi_levels
25-
multiple_virtual_inheritance
26-
results
24+
multiple_inheritance
2725

2826
INCLUDES
2927
.
@@ -38,6 +36,5 @@ libhal_build_demos(
3836
-fno-threadsafe-statics
3937

4038
LINK_FLAGS
41-
-Wl,-Map=link.map
4239
-fno-threadsafe-statics
4340
)

0 commit comments

Comments
 (0)