void _start (void) { /* It is important that these be declared `register'. Otherwise, when compiled without optimization, they are put on the stack, which loses completely after we zero the FP. */ register int argc; register char **argv, **envp; /* Unwind the frame built when we entered the function. */ asm("restore"); /* And clear the frame pointer. */ fp = 0; /* The argument info starts after one register window (64 bytes) past the SP. */ argc = ((int *) sp)[16]; argv = (char **) &((int *) sp)[17]; envp = &argv[argc + 1]; __environ = envp; #ifndef NO_SHLIB init_shlib (); #endif /* Allocate 24 bytes of stack space for the register save area. */ sp -= 24; __libc_init (argc, argv, envp); exit (main (argc, argv, envp)); }
_start() { /* unknown */ void Vfffffff4; (restore)ecx; ebx = esp; eax = esp; esp = esp & -8; eax = eax + ecx + ecx + ecx + ecx + 4; (save)0; (save)0; (save)0; ebp = esp; (save)eax; (save)ebx; (save)ecx; eax = 136; ebx = 0; asm("int 0x80"); __environ = Vfffffff4; __setfpucw(__fpu_control & -1); __libc_init(); atexit(_fini); _init(); main(); (save)eax; exit(); (restore)ebx; eax = 1; asm("int 0x80"); goto done; }
__LIBC_HIDDEN__ void do_mips_start(void *raw_args) { structors_array_t array; array.preinit_array = &__PREINIT_ARRAY__; array.init_array = &__INIT_ARRAY__; array.fini_array = &__FINI_ARRAY__; __libc_init(raw_args, NULL, &main, &array); }
void noahos_main(int base, void (*entry)(void), int argc, char **argv) { __libc_init(); main(argc, argv); for(;;) { TaskTerminate(TaskSelf()); } }
void _start() { structors_array_t array; void *elfdata; array.preinit_array = &__PREINIT_ARRAY__; array.init_array = &__INIT_ARRAY__; array.fini_array = &__FINI_ARRAY__; elfdata = __builtin_frame_address(0) + sizeof(void *); __libc_init(elfdata, (void *) 0, &main, &array); }
bool DllMainCRTStartup(module_info_t *mod, unsigned reason) { switch (reason) { case DLLMAIN_PROCESS_STARTUP: __libc_init(); break; } return true; }
/* _start calls this on the new stack. */ static volatile void start1 (void) { __libc_init (start_argc, start_argv, __environ); (_cthread_exit_routine != NULL ? *_cthread_exit_routine : exit) (main (start_argc, start_argv, __environ)); /* Should never get here. */ LOSE; }
void _start() { structors_array_t array; array.preinit_array = &__PREINIT_ARRAY__; array.init_array = &__INIT_ARRAY__; array.fini_array = &__FINI_ARRAY__; void* raw_args = (void*) ((uintptr_t) __builtin_frame_address(0) + sizeof(void*)); #ifdef __x86_64__ // 16-byte stack alignment is required by x86_64 ABI asm("andq $~15, %rsp"); #endif __libc_init(raw_args, NULL, &main, &array); }
// ARC MOD BEGIN // Use an argument |info| to pass |elfdata|, following NaCl's calling // convention. See nacl-glibc/sysdeps/nacl/start.c. void _start(unsigned **info) { // ARC MOD END structors_array_t array; array.preinit_array = &__PREINIT_ARRAY__; array.init_array = &__INIT_ARRAY__; array.fini_array = &__FINI_ARRAY__; // ARC MOD BEGIN // Get |raw_args| from |info|. void* raw_args = &info[2]; // ARC MOD END #ifdef __x86_64__ // 16-byte stack alignment is required by x86_64 ABI asm("andq $~15, %rsp"); #endif __libc_init(raw_args, NULL, &main, &array); }
void __prex_main(int argc, char *argv[], char *envp[]) { char *ap; environ = envp; if ((ap = argv[0])) { if ((__progname = _strrchr(ap, '/')) == NULL) __progname = ap; else ++__progname; } __libc_init(); exit(main(argc, argv, envp)); /* NOTREACHED */ }
static void init1 (int argc, char *arg0, ...) { char **argv = &arg0; char **envp = &argv[argc + 1]; struct hurd_startup_data *d; __libc_argc = argc; __libc_argv = argv; __environ = envp; while (*envp) ++envp; d = (void *) ++envp; /* If we are the bootstrap task started by the kernel, then after the environment pointers there is no Hurd data block; the argument strings start there. */ if ((void *) d != argv[0]) { _hurd_init_dtable = d->dtable; _hurd_init_dtablesize = d->dtablesize; { /* Check if the stack we are now on is different from the one described by _hurd_stack_{base,size}. */ char dummy; const vm_address_t newsp = (vm_address_t) &dummy; if (d->stack_size != 0 && (newsp < d->stack_base || newsp - d->stack_base > d->stack_size)) /* The new stack pointer does not intersect with the stack the exec server set up for us, so free that stack. */ __vm_deallocate (__mach_task_self (), d->stack_base, d->stack_size); } } if (__hurd_threadvar_stack_mask == 0) { /* We are not using cthreads, so we will have just a single allocated area for the per-thread variables of the main user thread. */ unsigned long int i; __hurd_threadvar_stack_offset = (unsigned long int) malloc (__hurd_threadvar_max * sizeof (unsigned long int)); if (__hurd_threadvar_stack_offset == 0) __libc_fatal ("Can't allocate single-threaded per-thread variables."); for (i = 0; i < __hurd_threadvar_max; ++i) ((unsigned long int *) __hurd_threadvar_stack_offset)[i] = 0; } if ((void *) d != argv[0] && (d->portarray || d->intarray)) /* Initialize library data structures, start signal processing, etc. */ _hurd_init (d->flags, argv, d->portarray, d->portarraysize, d->intarray, d->intarraysize); __libc_init (argc, argv, __environ); #ifdef USE_NONOPTION_FLAGS /* This is a hack to make the special getopt in GNU libc working. */ __getopt_clean_environment (envp); #endif #ifdef SHARED __libc_global_ctors (); #endif (void) &init1; }
void libSystem_initializer(int argc, const char* argv[], const char* envp[], const char* apple[], const struct ProgramVars* vars) { static const struct _libkernel_functions libkernel_funcs = { .version = 1, .dlsym = dlsym, .malloc = malloc, .free = free, .realloc = realloc, ._pthread_exit_if_canceled = _pthread_exit_if_canceled, }; static const struct _libpthread_functions libpthread_funcs = { .version = 1, .exit = exit, }; __libkernel_init(&libkernel_funcs, envp, apple, vars); bootstrap_init(); __libplatform_init(NULL, envp, apple, vars); __pthread_init(&libpthread_funcs, envp, apple, vars); __libc_init(vars, libSystem_atfork_prepare, libSystem_atfork_parent, libSystem_atfork_child, apple); // TODO: Move __malloc_init before __libc_init after breaking malloc's upward link to Libc __malloc_init(apple); _dyld_initializer(); libdispatch_init(); _libxpc_initializer(); __stack_logging_early_finished(); /* <rdar://problem/11588042> * C99 standard has the following in section 7.5(3): * "The value of errno is zero at program startup, but is never set * to zero by any library function." */ errno = 0; } /* * libSystem_atfork_{prepare,parent,child}() are called by libc when we fork, then we deal with running fork handlers * for everyone else. */ void libSystem_atfork_prepare(void) { _libSC_info_fork_prepare(); xpc_atfork_prepare(); dispatch_atfork_prepare(); _pthread_fork_prepare(); _malloc_fork_prepare(); } void libSystem_atfork_parent(void) { _malloc_fork_parent(); _pthread_fork_parent(); dispatch_atfork_parent(); xpc_atfork_parent(); _libSC_info_fork_parent(); }