static void (*const __CTOR_LIST__[1]) (void) __attribute__ ((section (".ctors"))) = { (void (*) (void)) -1 }; static void (*const __DTOR_LIST__[1]) (void) __attribute__ ((section (".dtors"))) = { (void (*) (void)) -1 }; extern void __uClibc_main(int argc,void *argv,void *envp); extern int atexit (void (*__func) (void)); void __do_global_ctors(void); asm( ".text\n" "\t.global\t_start\n" "\t.type\t_start,@function\n" "\n" ".text\n" "_start:\n" "\t.cpload\t$25\n" "\tmove\t$30, $0\n" /* zero frame pointer */ "\tlw\t$4, 0($29)\n" /* $4 = argc */ "\taddu\t$5, $29, 4\n" /* $5 = argv */ "\tmove\t$6, $4\n" /* $6 = envp = (argc+1)*4+argv */ "\tadd\t$6, 1\n" "\tsll\t$6, 2\n" "\taddu\t$6, $6, $5\n" "\n" /* Ok, now run uClibc's main() -- shouldn't return */ "\tjal\t__do_global_ctors\n" "\tjal\t__uClibc_main\n" ); static inline void run_hooks (void (*const list[]) (void)) { while (*++list) (**list) (); } void __do_global_dtors (void) { run_hooks (__DTOR_LIST__); } void __do_global_ctors(void) { run_hooks (__CTOR_LIST__); atexit (__do_global_dtors); }