@joerg
newlib doesn't use the same clib2 mechanism for constructors. newlib doesn't have CONSTRUCTOR defines that clib2 (original too) has. If you try to change the clib2 crtbegin/end files trying to change .ctors/.dtors to ~0/1 nothing will work with current gcc (don't know the ancient version of 20 years ago). If you think that this can be fixed of course feel free to send a pull request
That's the beauty of open source
@LiveForIt
Libraries are always closed correctly inside clib2 function that call main because exit will jump into longjmp that will call the routine that will close the libraries, call the destructors and so on.
Why setup and use pr_ExitCode and pr_FinalCode?
I'll fix the closing routine that will set the pointers to NULL.