mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-21 12:30:06 +00:00
[BZ #974]
2005-04-13 H.J. Lu <hongjiu.lu@intel.com> [BZ #974] * csu/elf-init.c (__preinit_array_start): Take int, char **, char **. (__preinit_array_end): Likewise. (__init_array_start): Likewise. (__init_array_end): Likewise. (__libc_csu_init): Take int argc, char **argv, char **envp. Call preinit_array and init_array with argc, argv, envp. * sysdeps/generic/libc-start.c (LIBC_START_MAIN): Remove INIT_MAIN_ARGS. * sysdeps/powerpc/elf/libc-start.c (INIT_MAIN_ARGS): Removed. * elf/Makefile (distribute): Add tst-array5.c, tst-array5-static.c, tst-array5dep.c, and tst-array5.exp. (tests): Add tst-array5. (tests-static): Add tst-array5-static. ($(objpfx)tst-array5): New target. ($(objpfx)tst-array5.out): Likewise. ($(objpfx)tst-array5-static.out): Likewise. * elf/tst-array5-static.c: New file. * elf/tst-array5-static.exp: Likewise. * elf/tst-array5.c: Likewise. * elf/tst-array5.exp: Likewise. * elf/tst-array5dep.c: Likewise.
This commit is contained in:
parent
6f8116b3ab
commit
04395c90fc
25
ChangeLog
25
ChangeLog
@ -1,3 +1,28 @@
|
||||
2005-04-13 H.J. Lu <hongjiu.lu@intel.com>
|
||||
|
||||
[BZ #974]
|
||||
* csu/elf-init.c (__preinit_array_start): Take int, char **, char **.
|
||||
(__preinit_array_end): Likewise.
|
||||
(__init_array_start): Likewise.
|
||||
(__init_array_end): Likewise.
|
||||
(__libc_csu_init): Take int argc, char **argv, char **envp.
|
||||
Call preinit_array and init_array with argc, argv, envp.
|
||||
* sysdeps/generic/libc-start.c (LIBC_START_MAIN): Remove
|
||||
INIT_MAIN_ARGS.
|
||||
* sysdeps/powerpc/elf/libc-start.c (INIT_MAIN_ARGS): Removed.
|
||||
* elf/Makefile (distribute): Add tst-array5.c, tst-array5-static.c,
|
||||
tst-array5dep.c, and tst-array5.exp.
|
||||
(tests): Add tst-array5.
|
||||
(tests-static): Add tst-array5-static.
|
||||
($(objpfx)tst-array5): New target.
|
||||
($(objpfx)tst-array5.out): Likewise.
|
||||
($(objpfx)tst-array5-static.out): Likewise.
|
||||
* elf/tst-array5-static.c: New file.
|
||||
* elf/tst-array5-static.exp: Likewise.
|
||||
* elf/tst-array5.c: Likewise.
|
||||
* elf/tst-array5.exp: Likewise.
|
||||
* elf/tst-array5dep.c: Likewise.
|
||||
|
||||
2005-07-07 Ulrich Drepper <drepper@redhat.com>
|
||||
|
||||
* sysdeps/unix/sysv/linux/bits/sched.h: Adjust clone prototype.
|
||||
|
@ -38,10 +38,14 @@
|
||||
|
||||
#ifdef HAVE_INITFINI_ARRAY
|
||||
/* These magic symbols are provided by the linker. */
|
||||
extern void (*__preinit_array_start []) (void) attribute_hidden;
|
||||
extern void (*__preinit_array_end []) (void) attribute_hidden;
|
||||
extern void (*__init_array_start []) (void) attribute_hidden;
|
||||
extern void (*__init_array_end []) (void) attribute_hidden;
|
||||
extern void (*__preinit_array_start []) (int, char **, char **)
|
||||
attribute_hidden;
|
||||
extern void (*__preinit_array_end []) (int, char **, char **)
|
||||
attribute_hidden;
|
||||
extern void (*__init_array_start []) (int, char **, char **)
|
||||
attribute_hidden;
|
||||
extern void (*__init_array_end []) (int, char **, char **)
|
||||
attribute_hidden;
|
||||
extern void (*__fini_array_start []) (void) attribute_hidden;
|
||||
extern void (*__fini_array_end []) (void) attribute_hidden;
|
||||
#endif
|
||||
@ -57,7 +61,7 @@ extern void _fini (void);
|
||||
the libc.a module in that it doesn't call the preinit array. */
|
||||
|
||||
void
|
||||
__libc_csu_init (void)
|
||||
__libc_csu_init (int argc, char **argv, char **envp)
|
||||
{
|
||||
#ifdef HAVE_INITFINI_ARRAY
|
||||
/* For dynamically linked executables the preinit array is executed by
|
||||
@ -69,7 +73,7 @@ __libc_csu_init (void)
|
||||
const size_t size = __preinit_array_end - __preinit_array_start;
|
||||
size_t i;
|
||||
for (i = 0; i < size; i++)
|
||||
(*__preinit_array_start [i]) ();
|
||||
(*__preinit_array_start [i]) (argc, argv, envp);
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
@ -81,7 +85,7 @@ __libc_csu_init (void)
|
||||
const size_t size = __init_array_end - __init_array_start;
|
||||
size_t i;
|
||||
for (i = 0; i < size; i++)
|
||||
(*__init_array_start [i]) ();
|
||||
(*__init_array_start [i]) (argc, argv, envp);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
21
elf/Makefile
21
elf/Makefile
@ -88,7 +88,9 @@ distribute := rtld-Rules \
|
||||
unload4mod1.c unload4mod2.c unload4mod3.c unload4mod4.c \
|
||||
unload6mod1.c unload6mod2.c unload6mod3.c tst-auditmod1.c \
|
||||
order2mod1.c order2mod2.c order2mod3.c order2mod4.c \
|
||||
tst-stackguard1.c tst-stackguard1-static.c
|
||||
tst-stackguard1.c tst-stackguard1-static.c \
|
||||
tst-array5.c tst-array5-static.c tst-array5dep.c \
|
||||
tst-array5.exp
|
||||
|
||||
CFLAGS-dl-runtime.c = -fexceptions -fasynchronous-unwind-tables
|
||||
CFLAGS-dl-lookup.c = -fexceptions -fasynchronous-unwind-tables
|
||||
@ -138,7 +140,7 @@ endif
|
||||
|
||||
tests = tst-tls1 tst-tls2 tst-tls9
|
||||
ifeq (yes,$(have-initfini-array))
|
||||
tests += tst-array1 tst-array2 tst-array3 tst-array4
|
||||
tests += tst-array1 tst-array2 tst-array3 tst-array4 tst-array5
|
||||
endif
|
||||
ifeq (yes,$(build-static))
|
||||
tests-static = tst-tls1-static tst-tls2-static tst-stackguard1-static
|
||||
@ -148,7 +150,7 @@ tst-tls9-static-ENV = \
|
||||
LD_LIBRARY_PATH=$(objpfx):$(common-objpfx):$(common-objpfx)dlfcn
|
||||
endif
|
||||
ifeq (yes,$(have-initfini-array))
|
||||
tests-static += tst-array1-static
|
||||
tests-static += tst-array1-static tst-array5-static
|
||||
endif
|
||||
tests += $(tests-static)
|
||||
endif
|
||||
@ -206,7 +208,7 @@ modules-names = testobj1 testobj2 testobj3 testobj4 testobj5 testobj6 \
|
||||
unload6mod1 unload6mod2 unload6mod3 \
|
||||
order2mod1 order2mod2 order2mod3 order2mod4
|
||||
ifeq (yes,$(have-initfini-array))
|
||||
modules-names += tst-array2dep
|
||||
modules-names += tst-array2dep tst-array5dep
|
||||
endif
|
||||
ifeq (yesyes,$(have-fpie)$(build-shared))
|
||||
modules-names += tst-piemod1
|
||||
@ -767,6 +769,17 @@ $(objpfx)tst-array4.out: $(objpfx)tst-array4 $(objpfx)tst-array2dep.so
|
||||
$< > $@
|
||||
cmp $@ tst-array4.exp > /dev/null
|
||||
|
||||
$(objpfx)tst-array5: $(objpfx)tst-array5dep.so
|
||||
$(objpfx)tst-array5.out: $(objpfx)tst-array5
|
||||
$(elf-objpfx)$(rtld-installed-name) \
|
||||
--library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)) \
|
||||
$(objpfx)tst-array5 > $@
|
||||
cmp $@ tst-array5.exp > /dev/null
|
||||
|
||||
$(objpfx)tst-array5-static.out: $(objpfx)tst-array5-static
|
||||
$(objpfx)tst-array5-static > $@
|
||||
cmp $@ tst-array5-static.exp > /dev/null
|
||||
|
||||
ifeq (yesyes,$(have-fpie)$(build-shared))
|
||||
CFLAGS-tst-pie1.c += -fpie
|
||||
|
||||
|
1
elf/tst-array5-static.c
Normal file
1
elf/tst-array5-static.c
Normal file
@ -0,0 +1 @@
|
||||
#include "tst-array5.c"
|
2
elf/tst-array5-static.exp
Normal file
2
elf/tst-array5-static.exp
Normal file
@ -0,0 +1,2 @@
|
||||
preinit array in executable: tst-array5-static
|
||||
init array in executable: tst-array5-static
|
50
elf/tst-array5.c
Normal file
50
elf/tst-array5.c
Normal file
@ -0,0 +1,50 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static void
|
||||
preinit_0 (int argc __attribute__ ((unused)), char **argv)
|
||||
{
|
||||
char *p = strrchr (argv [0], '/');
|
||||
|
||||
if (p == NULL)
|
||||
return;
|
||||
|
||||
p++;
|
||||
size_t len = strlen (p);
|
||||
write (STDOUT_FILENO, "preinit array in executable: ", 29);
|
||||
write (STDOUT_FILENO, p, len);
|
||||
write (STDOUT_FILENO, "\n", 1);
|
||||
}
|
||||
|
||||
void (*const preinit_array []) (int, char **)
|
||||
__attribute__ ((section (".preinit_array"), aligned (sizeof (void *)))) =
|
||||
{
|
||||
&preinit_0,
|
||||
};
|
||||
|
||||
static void
|
||||
init_0 (int argc __attribute__ ((unused)), char **argv)
|
||||
{
|
||||
char *p = strrchr (argv [0], '/');
|
||||
|
||||
if (p == NULL)
|
||||
return;
|
||||
|
||||
p++;
|
||||
size_t len = strlen (p);
|
||||
write (STDOUT_FILENO, "init array in executable: ", 26);
|
||||
write (STDOUT_FILENO, p, len);
|
||||
write (STDOUT_FILENO, "\n", 1);
|
||||
}
|
||||
|
||||
void (*const init_array []) (int, char **)
|
||||
__attribute__ ((section (".init_array"), aligned (sizeof (void *)))) =
|
||||
{
|
||||
&init_0,
|
||||
};
|
||||
|
||||
int
|
||||
main (void)
|
||||
{
|
||||
return 0;
|
||||
}
|
3
elf/tst-array5.exp
Normal file
3
elf/tst-array5.exp
Normal file
@ -0,0 +1,3 @@
|
||||
preinit array in executable: tst-array5
|
||||
init array in DSO: tst-array5
|
||||
init array in executable: tst-array5
|
23
elf/tst-array5dep.c
Normal file
23
elf/tst-array5dep.c
Normal file
@ -0,0 +1,23 @@
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static void
|
||||
init_0 (int argc __attribute__ ((unused)), char **argv)
|
||||
{
|
||||
char *p = strrchr (argv [0], '/');
|
||||
|
||||
if (p == NULL)
|
||||
return;
|
||||
|
||||
p++;
|
||||
size_t len = strlen (p);
|
||||
write (STDOUT_FILENO, "init array in DSO: ", 19);
|
||||
write (STDOUT_FILENO, p, len);
|
||||
write (STDOUT_FILENO, "\n", 1);
|
||||
}
|
||||
|
||||
void (*const init_array []) (int, char **)
|
||||
__attribute__ ((section (".init_array"), aligned (sizeof (void *)))) =
|
||||
{
|
||||
&init_0,
|
||||
};
|
@ -75,11 +75,7 @@ STATIC int LIBC_START_MAIN (int (*main) (int, char **, char **
|
||||
#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)
|
||||
@ -95,11 +91,7 @@ LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL),
|
||||
#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)
|
||||
{
|
||||
@ -195,11 +187,7 @@ LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL),
|
||||
GLRO(dl_debug_printf) ("\ninitialize program: %s\n\n", argv[0]);
|
||||
#endif
|
||||
if (init)
|
||||
(*init) (
|
||||
#ifdef INIT_MAIN_ARGS
|
||||
argc, argv, __environ MAIN_AUXVEC_PARAM
|
||||
#endif
|
||||
);
|
||||
(*init) (argc, argv, __environ MAIN_AUXVEC_PARAM);
|
||||
|
||||
#ifdef SHARED
|
||||
/* Auditing checkpoint: we have a new object. */
|
||||
|
@ -30,7 +30,6 @@ weak_extern (__cache_line_size)
|
||||
#define LIBC_START_DISABLE_INLINE
|
||||
#define LIBC_START_MAIN_AUXVEC_ARG
|
||||
#define MAIN_AUXVEC_ARG
|
||||
#define INIT_MAIN_ARGS
|
||||
#include <sysdeps/generic/libc-start.c>
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user