Annotation of dietlibc/dyn_start.c, revision 1.3

1.2       olaf        1: #include "dietfeatures.h"
                      2: 
                      3: #ifdef WANT_DYNAMIC
1.1       olaf        4: #include <stdlib.h>
                      5: 
                      6: typedef void(*structor)(void);
                      7: 
                      8: #if 0 
                      9: 
                     10: /* OLD tricks are this still needed ? */
                     11: 
                     12: /* dirty trick to force gcc to be in the data section */
                     13: static structor force_to_data[0] = {};
                     14: 
                     15: /* next dirty tricks to make program/sharedlib "local" objects and functions */
                     16: 
                     17: asm ( ".section .ctors,\"aw\" "); /* now change the section without gcc knowing it ! */
                     18: static structor __CTOR_LIST__[1]={((structor)-1)};
                     19: 
                     20: asm ( ".section .dtors,\"aw\" "); /* here too a section change */
                     21: static structor __DTOR_LIST__[1]={((structor)-1)};
                     22: 
                     23: #endif
                     24: 
                     25: __attribute__((section(".ctors")))
                     26: static structor __CTOR_LIST__[1]={((structor)-1)};
                     27: 
                     28: __attribute__((section(".dtors")))
                     29: static structor __DTOR_LIST__[1]={((structor)-1)};
                     30: 
                     31: static void __do_global_dtors_aux(void)
                     32: {
                     33:   structor *df=__CTOR_LIST__;  /* ugly trick to prevent warning */
                     34:   for (df=((__DTOR_LIST__)+1);(*df) != (structor)0; df++) (*df)();
                     35: }
                     36: 
                     37: __attribute__((section(".fini"))) void _fini(void)
                     38: {
                     39:   __do_global_dtors_aux();
                     40: }
                     41: 
1.3     ! olaf       42: /* pre main, post _start */
        !            43: int _dyn_start(int argc, char **argv, char **envp, structor dl_init)
1.1       olaf       44: {
                     45:   static __attribute__((section(".init"))) void _init(void);
                     46:   int main(int argc, char **argv, char **envp);
                     47: 
                     48:   if (dl_init) atexit(dl_init);
                     49:   _init();
                     50:   atexit(_fini);
                     51:   return main(argc, argv, envp);
                     52: }
1.2       olaf       53: #endif

LinuxTV legacy CVS <linuxtv.org/cvs>