075 void (*fini) (void),
076 void (*rtld_fini) (void), 077 void *__unbounded stack_end) 078 __attribute ((noreturn)); 079 080 081 /** Note: the fini parameter is ignored here for shared library. It 082 is registered with __cxa_atexit. This had the disadvantage that 083 finalizers were called in more than one place. */ 084 STATIC int 085 LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL), 086 int argc, char * unbounded * unbounded ubp_av, 087 #ifdef LIBC_START_MAIN_AUXVEC_ARG 088 ElfW(auxv_t) * unbounded auxvec, 089 #endif 090 __typeof (main) init, 091 void (*fini) (void), 092 void (*rtld_fini) (void), void * unbounded stack_end)
093 {
094 #if BOUNDED_POINTERS 095 char **argv; 096 #else 097 # define argv ubp_av 098 #endif 099 100 /** Result of the 'main' function. */ 101 int result; 102 103 libc_multiple_libcs = &_dl_starting_up && !_dl_starting_up; 104 105 #ifndef SHARED 106 char * unbounded *__unbounded ubp_ev = &ubp_av[argc + 1]; 107 108 INIT_ARGV_and_ENVIRON; 109 110 /** Store the lowest stack address. This is done in ld.so if this is 111 the code for the DSO. */ 112 libc_stack_end = stack_end; 113 114 # ifdef HAVE_AUX_VECTOR 115 /** First process the auxiliary vector since we need to find the 116 program header to locate an eventually present PT_TLS entry. */ 117 # ifndef LIBC_START_MAIN_AUXVEC_ARG 118 ElfW(auxv_t) * unbounded auxvec; 119 { 120 char * unbounded * unbounded evp = ubp_ev; 121 while (*evp++ != NULL) 122 ; 123 auxvec = (ElfW(auxv_t) *__unbounded) evp; 124 } 125 # endif 126 _dl_aux_init (auxvec); 127 # endif 128 # ifdef DL_SYSDEP_OSCHECK 129 if (! libc_multiple_libcs) 130 { 131 /** This needs to run to initiliaze _dl_osversion before TLS 132 setup might check it. */ 133 DL_SYSDEP_OSCHECK ( libc_fatal); 134 } 135 # endif 136 137 /** Initialize the thread library at least a bit since the libgcc 138 functions are using thread functions if these are available and 139 we need to setup errno. */ 140 pthread_initialize_minimal (); 141
142 /** Set up the stack checker's canary. */
143 uintptr_t stack_chk_guard = _dl_setup_stack_chk_guard (); 144 # ifdef THREAD_SET_STACK_GUARD 145 THREAD_SET_STACK_GUARD (stack_chk_guard); 146 # else 147 stack_chk_guard = stack_chk_guard; 148 # endif 149 #endif 150 151 /** Register the destructor of the dynamic linker if there is any. */ 152 if ( builtin_expect (rtld_fini != NULL, 1))
153
154 cxa_atexit ((void (*) (void *)) rtld_fini, NULL, NULL);
155 #ifndef SHARED 156 /** Call the initializer of the libc. This is only needed here if we |