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 (;;) ; }