/* See LICENSE of license details. */ #include "weak_under_alias.h" #include #include #if defined(SEMIHOSTING) #include "semihosting.h" #endif #if defined(BOARD_hifive1) static volatile uint32_t tohost; static volatile uint32_t fromhost; #else extern volatile uint32_t tohost; 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) { #ifndef HAVE_NO_INIT_FINI __libc_fini_array(); #endif const char message[] = "\nProgam has exited with code:"; write(STDERR_FILENO, message, sizeof(message) - 1); write_hex(STDERR_FILENO, code); write(STDERR_FILENO, "\n", 1); tohost = (code << 1) + 1; for (;;) ; } weak_under_alias(exit);