Index: configure.ac ================================================================== --- configure.ac +++ configure.ac @@ -59,12 +59,13 @@ AC_SUBST(SFDC_INLINE_H, inline.h) dnl For 68000, GCC emits calls to helper functions that dnl do not work properly in a library. t="-mcpu=68020 -fbaserel -noixemul" AC_SUBST(AMIGA_LIB_CFLAGS, "$t -ffreestanding") - AC_SUBST(AMIGA_LIB_LDFLAGS, - "$t -resident -nostartfiles -ldebug -lc") + t="$t -resident -nostartfiles -nodefaultlibs" + t="$t -ldebug -lc" + AC_SUBST(AMIGA_LIB_LDFLAGS, $t) ]) AC_SUBST(LIBBASES_M, libbases.m) ;; powerpc-*-amigaos*) Index: src/runtime/amiga-library.m ================================================================== --- src/runtime/amiga-library.m +++ src/runtime/amiga-library.m @@ -45,10 +45,17 @@ int _start() { return -1; } + +#ifdef OF_AMIGAOS_M68K +void +__init_eh(void) +{ +} +#endif struct ObjFWRTBase { struct Library library; void *segList; struct ObjFWRTBase *parent; @@ -594,15 +601,21 @@ va_list args) { return libc.vsnprintf(str, size, fmt, args); } #endif + +int +atexit(void (*function)(void)) +{ + return libc.atexit(function); +} void -abort(void) +exit(int status) { - libc.abort(); + libc.exit(status); OF_UNREACHABLE } #pragma GCC diagnostic push Index: src/runtime/linklib/linklib.m ================================================================== --- src/runtime/linklib/linklib.m +++ src/runtime/linklib/linklib.m @@ -115,11 +115,12 @@ #endif .get_errno = get_errno, #ifdef OF_AMIGAOS_M68K .vsnprintf = vsnprintf, #endif - .abort = abort, + .atexit = atexit, + .exit = exit, }; if (initialized) return; Index: src/runtime/misc.m ================================================================== --- src/runtime/misc.m +++ src/runtime/misc.m @@ -84,10 +84,12 @@ EasyRequest(NULL, &easy, NULL, (ULONG)message); CloseLibrary(IntuitionBase); } + + exit(EXIT_FAILURE); # undef BUF_LEN #else va_list args; va_start(args, format); @@ -96,10 +98,11 @@ vfprintf(stderr, format, args); vfprintf(stderr, "\n"); fflush(stderr); va_end(args); -#endif + abort(); +#endif OF_UNREACHABLE } Index: src/runtime/private.h ================================================================== --- src/runtime/private.h +++ src/runtime/private.h @@ -257,11 +257,12 @@ int *_Nonnull (*_Nonnull get_errno)(void); # ifdef OF_AMIGAOS_M68K int (*_Nonnull vsnprintf)(char *restrict _Nonnull str, size_t size, const char *_Nonnull restrict fmt, va_list args); # endif - void (*_Nonnull abort)(void); + int (*_Nonnull atexit)(void (*_Nonnull)(void)); + void (*_Nonnull exit)(int); }; #endif #ifdef OBJC_COMPILING_AMIGA_LIBRARY # if defined(__MORPHOS__)