Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* csu/elf-init.c (__libc_csu_fini): Enable if LIBC_NONSHARED
	isn't defined.
	* sysdeps/generic/libc-start.c (LIBC_START_MAIN): Call fini
	if SHARED isn't defined.
	* elf/Makefile (tests-static): Add tst-array1-static.
	($(objpfx)tst-array1-static.out): New target.
	* elf/tst-array1-static.c: New file.
  • Loading branch information
Ulrich Drepper committed Feb 14, 2005
1 parent e38c954 commit 43c59a7
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 7 deletions.
10 changes: 10 additions & 0 deletions ChangeLog
@@ -1,3 +1,13 @@
2005-02-14 H.J. Lu <hongjiu.lu@intel.com>

* csu/elf-init.c (__libc_csu_fini): Enable if LIBC_NONSHARED
isn't defined.
* sysdeps/generic/libc-start.c (LIBC_START_MAIN): Call fini
if SHARED isn't defined.
* elf/Makefile (tests-static): Add tst-array1-static.
($(objpfx)tst-array1-static.out): New target.
* elf/tst-array1-static.c: New file.

2005-02-11 Jakub Jelinek <jakub@redhat.com>

* debug/chk_fail.c (__chk_fail): Add a while (1) loop around
Expand Down
2 changes: 1 addition & 1 deletion csu/elf-init.c
Expand Up @@ -92,7 +92,7 @@ __libc_csu_init (void)
void
__libc_csu_fini (void)
{
#if 0
#ifndef LIBC_NONSHARED
#ifdef HAVE_INITFINI_ARRAY
size_t i = __fini_array_end - __fini_array_start;
while (i-- > 0)
Expand Down
7 changes: 7 additions & 0 deletions elf/Makefile
Expand Up @@ -138,6 +138,9 @@ tests += tst-array1 tst-array2 tst-array3 tst-array4
endif
ifeq (yes,$(build-static))
tests-static = tst-tls1-static tst-tls2-static
ifeq (yes,$(have-initfini-array))
tests-static += tst-array1-static
endif
ifeq (yesyesyes,$(build-static)$(build-shared)$(elf))
tests-static += tst-tls9-static
tst-tls9-static-ENV = \
Expand Down Expand Up @@ -701,6 +704,10 @@ $(objpfx)tst-array1.out: $(objpfx)tst-array1
$(objpfx)tst-array1 > $@
cmp $@ tst-array1.exp > /dev/null

$(objpfx)tst-array1-static.out: $(objpfx)tst-array1-static
$(objpfx)tst-array1-static > $@
cmp $@ tst-array1.exp > /dev/null

$(objpfx)tst-array2: $(objpfx)tst-array2dep.so
$(objpfx)tst-array2.out: $(objpfx)tst-array2
$(elf-objpfx)$(rtld-installed-name) \
Expand Down
1 change: 1 addition & 0 deletions elf/tst-array1-static.c
@@ -0,0 +1 @@
#include "tst-array1.c"
14 changes: 8 additions & 6 deletions sysdeps/generic/libc-start.c
Expand Up @@ -81,9 +81,9 @@ STATIC int LIBC_START_MAIN (int (*main) (int, char **, char **
__attribute__ ((noreturn));


/* Note: the fini parameter is ignored here. It used to be registered
with __cxa_atexit. This had the disadvantage that finalizers were
called in more than one place. */
/* Note: the fini parameter is ignored here for shared library. It
is registered with __cxa_atexit. This had the disadvantage that
finalizers were called in more than one place. */
STATIC int
LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL),
int argc, char *__unbounded *__unbounded ubp_av,
Expand Down Expand Up @@ -155,14 +155,16 @@ LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL),
if (__builtin_expect (rtld_fini != NULL, 1))
__cxa_atexit ((void (*) (void *)) rtld_fini, NULL, NULL);

#ifndef SHARED
/* Call the initializer of the libc. This is only needed here if we
are compiling for the static library in which case we haven't
run the constructors in `_dl_start_user'. */
#ifndef SHARED
__libc_init_first (argc, argv, __environ);
#endif

#ifndef SHARED
/* Register the destructor of the program, if any. */
if (fini)
__cxa_atexit ((void (*) (void *)) fini, NULL, NULL);

/* Some security at this point. Prevent starting a SUID binary where
the standard file descriptors are not opened. We have to do this
only for statically linked applications since otherwise the dynamic
Expand Down

0 comments on commit 43c59a7

Please sign in to comment.