diff options
Diffstat (limited to 'sysdeps/i386/init-first.c')
-rw-r--r-- | sysdeps/i386/init-first.c | 45 |
1 files changed, 32 insertions, 13 deletions
diff --git a/sysdeps/i386/init-first.c b/sysdeps/i386/init-first.c index aa36732f60..792702e024 100644 --- a/sysdeps/i386/init-first.c +++ b/sysdeps/i386/init-first.c @@ -20,26 +20,45 @@ Cambridge, MA 02139, USA. */ #include <unistd.h> extern void __libc_init (int, char **, char **); +extern void __libc_global_ctors (void); + + +static void +init (int *data) +{ + int argc = *data; + char **argv = (void *) (data + 1); + char **envp = &argv[argc + 1]; + + __environ = envp; + __libc_init (argc, argv, envp); +} #ifdef PIC -static void soinit (int argc, char *arg0, ...) - __attribute__ ((unused, section (".init"))); +/* This function is called to initialize the shared C library. + It is called just before the user _start code from i386/elf/start.S, + with the stack set up as that code gets it. */ + +/* NOTE! The linker notices the magical name `_init' and sets the DT_INIT + pointer in the dynamic section based solely on that. It is convention + for this function to be in the `.init' section, but the symbol name is + the only thing that really matters!! */ +/*void _init (int argc, ...) __attribute__ ((unused, section (".init")));*/ void -__libc_init_first (void) +_init (int argc, ...) { + init (&argc); + + __libc_global_ctors (); } #endif -#ifdef PIC -static void soinit -#else -void __libc_init_first -#endif -(int argc, char *arg0, ...) -{ - char **argv = &arg0, **envp = &argv[argc + 1]; - __environ = envp; - __libc_init (argc, argv, envp); +void +__libc_init_first (int argc __attribute__ ((unused)), ...) +{ +#ifndef PIC + init (&argc); +#endif } |