The startup codes do the following:
extern struct WBStartup *_WBenchMsg
you can simply look into this place (and test for a ‘NULL’ pointer) to check if your program was started from WB. If this is a ‘NULL’ pointer
extern char *__commandline
contains the (‘\n’ terminated) parameters of the commandline.
with ascending priority.
int main(int argc,char *argv)
You can exit by simply falling through the end of ‘main’ or by calling
__volatile void exit(int returncode)
which does the cleanup:
with descending priority.
‘__INIT_LIST__’ and ‘__EXIT_LIST__’ are two set elements which are a speciality of the gnu ld. Since everything that needs initialization works over these two lists the bare startups are very short. In fact they are even shorter then some low-level-startups
You can easily add your own functions to the startup procedure by using the macros in the file ‘headers/stabs.h’ - but keep in mind that this is non-portable. Priority values <=0 are reserved for library implementors.