Skip to content

Commit b67d863

Browse files
committed
Disable registration of atexit handlers on ARMCC.
This prevent destructors for global C++ objects to be invoked at exit. By default atexit handlers registration involved dynamic allocation.
1 parent 2f0b772 commit b67d863

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

hal/common/retarget.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,31 @@ extern "C" void exit(int return_code) {
629629
} //namespace std
630630
#endif
631631

632+
#if defined(TOOLCHAIN_ARM)
633+
634+
// This series of function disable the registration of global destructors
635+
// in a dynamic table which will be called when the application exit.
636+
// In mbed, program never exit properly, it dies.
637+
// More informations about this topic for ARMCC here:
638+
// http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.faqs/6449.html
639+
extern "C" {
640+
int __aeabi_atexit(void *object, void (*dtor)(void* /*this*/), void *handle) {
641+
return 1;
642+
}
643+
644+
int __cxa_atexit(void (*dtor)(void* /*this*/), void *object, void *handle) {
645+
return 1;
646+
}
647+
648+
void __cxa_finalize(void *handle) {
649+
}
650+
651+
} // end of extern "C"
652+
653+
654+
#endif
655+
656+
632657

633658
namespace mbed {
634659

0 commit comments

Comments
 (0)