Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion cores/esp8266/core_esp8266_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,16 +279,23 @@ static void loop_task(os_event_t *events) {
ESP.setDramHeap();
}

#if __cpp_exceptions
extern "C" {
struct object { long placeholder[ 10 ]; };
void __register_frame_info (const void *begin, struct object *ob);
extern char __eh_frame[];
}

static void do_global_ctors(void) {
static void do_register_frame_info() {
static struct object ob;
__register_frame_info( __eh_frame, &ob );
}
#else
static void do_register_frame_info() {
}
#endif

static void do_global_ctors(void) {
void (**p)(void) = &__init_array_end;
while (p != &__init_array_start)
(*--p)();
Expand Down Expand Up @@ -322,6 +329,7 @@ void init_done() {
system_set_os_print(1);
gdb_init();
std::set_terminate(__unhandled_exception_cpp);
do_register_frame_info();
do_global_ctors();
esp_schedule();
ESP.setDramHeap();
Expand Down
31 changes: 31 additions & 0 deletions cores/esp8266/libgcc_replacements.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/* replaces libgcc weak functions with stubs when exceptions are disabled
* ref. gcc-gnu/libgcc/crtstuff.c
*
* in case something calls them w/ -fno-exceptions
*/

#if !defined(__cpp_exceptions)
#include <cstdlib> // std::abort()
#endif

extern "C" {

#if !defined(__cpp_exceptions)
void __register_frame_info (const void*, struct object*) {
std::abort();
}

void __register_frame_info_bases (const void*, struct object*, void*, void*) {
std::abort();
}

void* __deregister_frame_info (const void*) {
std::abort();
}

void* __deregister_frame_info_bases (const void*) {
std::abort();
}
#endif

} // extern "C"
Loading