From 6e2a7a12fe59238fca0a807cee68f3a4a2678c5c Mon Sep 17 00:00:00 2001 From: Eyck-Alexander Jentzsch Date: Fri, 23 May 2025 09:32:09 +0200 Subject: [PATCH] cleans up_exit, adds call to C++ destructors --- libwrap/sys/_exit.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/libwrap/sys/_exit.c b/libwrap/sys/_exit.c index 30c8293..5511705 100644 --- a/libwrap/sys/_exit.c +++ b/libwrap/sys/_exit.c @@ -1,9 +1,8 @@ /* See LICENSE of license details. */ #include "weak_under_alias.h" -//#include -#include #include +#include #if defined(SEMIHOSTING) #include "semihosting.h" #endif @@ -17,19 +16,17 @@ extern volatile uint32_t fromhost; #endif void write_hex(int fd, uint32_t hex); +extern void __libc_fini_array(void); void __wrap_exit(int code) { - - // volatile uint32_t* leds = (uint32_t*) (GPIO_BASE_ADDR + GPIO_OUT_OFFSET); +#ifndef HAVE_NO_INIT_FINI + __libc_fini_array(); +#endif const char message[] = "\nProgam has exited with code:"; - //*leds = (~(code)); write(STDERR_FILENO, message, sizeof(message) - 1); write_hex(STDERR_FILENO, code); write(STDERR_FILENO, "\n", 1); - write(STDERR_FILENO, "\n", 1); - // tohost = (code << 1) + 1; // here used to stop simulation - write(STDERR_FILENO, "\x04", 1); - + tohost = (code << 1) + 1; for (;;) ; }