Quote:
Your _fini(void) function can't work because int j (why static?) isn't initialized to 0 and therefore __DTOR_LIST__[j+1]() may be a random memory address and not a destructor function pointer from __DTOR_LIST__[]
As per the C standard, static variables are auto-initialized to 0 so it's not necessary to explicitly initialize them to 0. Nevertheless, I've just tried to initialize "j" to 0 explicitly but unsurprisingly this doesn't make a difference and the program crashes in the very same way with an instruction fault at address 0xC0DEFACC (sic!)
As to why "j" is declared static, no idea. As I said in the thread over at the Hyperion forums I took this code straight from clib2. It's the standard clib2 constructor/destructor (de)initialization code so I don't think there's anything wrong with it.
According to afxgroup's reply on the Hyperion forums it's a bug in the binutils which don't NULL-terminate the ctor/dtor lists on linking, thereby causing invalid ctors/dtors getting called. That's why I was hoping the latest binutils would fix the issue but it's still there :(