bebbo / libnix

libnix (v4): a C link library for AmigaOS/m68k
14 stars 9 forks source link

swapstack crash at exit #47

Closed BSzili closed 2 years ago

BSzili commented 2 years ago

I have an issue with swapstack.o as it causes a crash when the program exits, but only when the stack was replaced. I crated a minimal example program:

extern void __stkinit(void);
void * __x = __stkinit;
unsigned long __stack = (32*1024);
int main(void)
{
    return 0;
}

compile with: m68k-amigaos-gcc -noixemul -m68060 -m68881 -ffast-math -O2 -fomit-frame-pointer -o stkswap stkswaptest.c /opt/amiga/m68k-amigaos/libnix/lib/libm020/libm881/swapstack.o

It would also be convenient if swapstack.o was included in libnix20.a too and not just libnix13.a. That way there would be no need to specify the absolute path to have the correct version of swapstack. It shouldn't cause any issues for existing programs, as it wouldn't get linked unless __stkinit is referenced.

bebbo commented 2 years ago

the idea of including the file allows you to omit

extern void __stkinit(void);
void * __x = __stkinit;
BSzili commented 2 years ago

That would be even better, like it is in MorphOS, where you only need the unsigned long __stack global variable.