mirror of git://sourceware.org/git/glibc.git
2003-03-15 Roland McGrath <roland@redhat.com>
* sysdeps/generic/libc-start.c [LIBC_START_MAIN]: If defined, define a static function by that name instead of BP_SYM (__libc_start_main). [LIBC_START_MAIN_AUXVEC_ARG]: Take AUXVEC as argument. [MAIN_AUXVEC_ARG]: Pass 4th argument to MAIN. [INIT_MAIN_ARGS]: Give INIT the same args as MAIN.
This commit is contained in:
parent
7abed17041
commit
2b089f2101
|
|
@ -44,22 +44,51 @@ extern void __pthread_initialize_minimal (void)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
extern int BP_SYM (__libc_start_main) (int (*main) (int, char **, char **),
|
#ifdef LIBC_START_MAIN
|
||||||
int argc,
|
# define STATIC static inline
|
||||||
char *__unbounded *__unbounded ubp_av,
|
#else
|
||||||
void (*init) (void),
|
# define STATIC
|
||||||
void (*fini) (void),
|
# define LIBC_START_MAIN BP_SYM (__libc_start_main)
|
||||||
void (*rtld_fini) (void),
|
#endif
|
||||||
void *__unbounded stack_end)
|
|
||||||
|
STATIC int LIBC_START_MAIN (int (*main) (int, char **, char **
|
||||||
|
#ifdef MAIN_AUXVEC_ARG
|
||||||
|
, void *
|
||||||
|
#endif
|
||||||
|
|
||||||
|
),
|
||||||
|
int argc,
|
||||||
|
char *__unbounded *__unbounded ubp_av,
|
||||||
|
#ifdef LIBC_START_MAIN_AUXVEC_ARG
|
||||||
|
ElfW(auxv_t) *__unbounded auxvec,
|
||||||
|
#endif
|
||||||
|
#ifdef INIT_MAIN_ARGS
|
||||||
|
__typeof (main) init,
|
||||||
|
#else
|
||||||
|
void (*init) (void),
|
||||||
|
#endif
|
||||||
|
void (*fini) (void),
|
||||||
|
void (*rtld_fini) (void),
|
||||||
|
void *__unbounded stack_end)
|
||||||
__attribute__ ((noreturn));
|
__attribute__ ((noreturn));
|
||||||
|
|
||||||
int
|
STATIC int
|
||||||
/* GKM FIXME: GCC: this should get __BP_ prefix by virtue of the
|
LIBC_START_MAIN (int (*main) (int, char **, char **
|
||||||
BPs in the arglist of startup_info.main and startup_info.init. */
|
#ifdef MAIN_AUXVEC_ARG
|
||||||
BP_SYM (__libc_start_main) (int (*main) (int, char **, char **),
|
, void *
|
||||||
int argc, char *__unbounded *__unbounded ubp_av,
|
#endif
|
||||||
void (*init) (void), void (*fini) (void),
|
),
|
||||||
void (*rtld_fini) (void), void *__unbounded stack_end)
|
int argc, char *__unbounded *__unbounded ubp_av,
|
||||||
|
#ifdef LIBC_START_MAIN_AUXVEC_ARG
|
||||||
|
ElfW(auxv_t) *__unbounded auxvec,
|
||||||
|
#endif
|
||||||
|
#ifdef INIT_MAIN_ARGS
|
||||||
|
__typeof (main) init,
|
||||||
|
#else
|
||||||
|
void (*init) (void),
|
||||||
|
#endif
|
||||||
|
void (*fini) (void),
|
||||||
|
void (*rtld_fini) (void), void *__unbounded stack_end)
|
||||||
{
|
{
|
||||||
char *__unbounded *__unbounded ubp_ev = &ubp_av[argc + 1];
|
char *__unbounded *__unbounded ubp_ev = &ubp_av[argc + 1];
|
||||||
#if __BOUNDED_POINTERS__
|
#if __BOUNDED_POINTERS__
|
||||||
|
|
@ -80,13 +109,18 @@ BP_SYM (__libc_start_main) (int (*main) (int, char **, char **),
|
||||||
|
|
||||||
#ifndef SHARED
|
#ifndef SHARED
|
||||||
# ifdef HAVE_AUX_VECTOR
|
# ifdef HAVE_AUX_VECTOR
|
||||||
void *__unbounded *__unbounded auxvec;
|
|
||||||
/* First process the auxiliary vector since we need to find the
|
/* First process the auxiliary vector since we need to find the
|
||||||
program header to locate an eventually present PT_TLS entry. */
|
program header to locate an eventually present PT_TLS entry. */
|
||||||
for (auxvec = (void *__unbounded *__unbounded) ubp_ev;
|
# ifndef LIBC_START_MAIN_AUXVEC_ARG
|
||||||
*auxvec != NULL; ++auxvec);
|
ElfW(auxv_t) *__unbounded auxvec;
|
||||||
++auxvec;
|
{
|
||||||
_dl_aux_init ((ElfW(auxv_t) *) auxvec);
|
char *__unbounded *__unbounded evp = uvp_ev;
|
||||||
|
while (*evp != NULL)
|
||||||
|
++evp;
|
||||||
|
auxvec = (ElfW(auxv_t) *__unbounded) evp;
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
_dl_aux_init (auxvec);
|
||||||
# endif
|
# endif
|
||||||
# ifdef DL_SYSDEP_OSCHECK
|
# ifdef DL_SYSDEP_OSCHECK
|
||||||
if (!__libc_multiple_libcs)
|
if (!__libc_multiple_libcs)
|
||||||
|
|
@ -136,7 +170,14 @@ BP_SYM (__libc_start_main) (int (*main) (int, char **, char **),
|
||||||
_dl_debug_printf ("\ninitialize program: %s\n\n", argv[0]);
|
_dl_debug_printf ("\ninitialize program: %s\n\n", argv[0]);
|
||||||
#endif
|
#endif
|
||||||
if (init)
|
if (init)
|
||||||
(*init) ();
|
(*init) (
|
||||||
|
#ifdef INIT_MAIN_ARGS
|
||||||
|
argc, argv, __environ
|
||||||
|
# ifdef MAIN_AUXVEC_ARG
|
||||||
|
, auxvec
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
);
|
||||||
|
|
||||||
#ifdef SHARED
|
#ifdef SHARED
|
||||||
if (__builtin_expect (GL(dl_debug_mask) & DL_DEBUG_IMPCALLS, 0))
|
if (__builtin_expect (GL(dl_debug_mask) & DL_DEBUG_IMPCALLS, 0))
|
||||||
|
|
@ -149,7 +190,12 @@ BP_SYM (__libc_start_main) (int (*main) (int, char **, char **),
|
||||||
{
|
{
|
||||||
/* XXX This is where the try/finally handling must be used. */
|
/* XXX This is where the try/finally handling must be used. */
|
||||||
|
|
||||||
result = main (argc, argv, __environ);
|
result = main (argc, argv, __environ
|
||||||
|
#ifdef MAIN_AUXVEC_ARG
|
||||||
|
, auxvec
|
||||||
|
#endif
|
||||||
|
|
||||||
|
);
|
||||||
}
|
}
|
||||||
#ifdef HAVE_CANCELBUF
|
#ifdef HAVE_CANCELBUF
|
||||||
else
|
else
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue