]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
2005-01-03 Ulrich Drepper <drepper@redhat.com>
authorRoland McGrath <roland@gnu.org>
Wed, 16 Feb 2005 09:40:56 +0000 (09:40 +0000)
committerRoland McGrath <roland@gnu.org>
Wed, 16 Feb 2005 09:40:56 +0000 (09:40 +0000)
[BZ #727]
* sysdeps/generic/libc-start.c [SHARED] (__libc_start_main): Don't
initialize __environ again.
* stdlib/Makefile: Add rules to build and run tst-putenv.
* stdlib/tst-putenv.c: New file.
* stdlib/tst-putenvmod.c: New file.

stdlib/Makefile
stdlib/tst-putenv.c [new file with mode: 0644]
stdlib/tst-putenvmod.c [new file with mode: 0644]
sysdeps/generic/libc-start.c

index 5f4675033e9a705dabec7ba29c0bfcfdea123873..8e9ef28cb47be9e419aa064a4157158acd8bfb80 100644 (file)
@@ -65,6 +65,11 @@ tests                := tst-strtol tst-strtod testmb testrand testsort testdiv   \
                   tst-rand48 bug-strtod tst-setcontext test-a64l tst-qsort \
                   tst-system testmb2
 
+include ../Makeconfig
+
+ifeq ($(build-shared),yes)
+tests          += tst-putenv
+endif
 
 # Several mpn functions from GNU MP are used by the strtod function.
 mpn-routines := inlines add_n addmul_1 cmp divmod_1 divrem udiv_qrnnd \
@@ -75,9 +80,13 @@ routines := $(strip $(routines) $(mpn-routines))     \
            dbl2mpn ldbl2mpn                            \
            mpn2flt mpn2dbl mpn2ldbl
 aux += fpioconst mp_clz_tab
-distribute := $(distribute) $(mpn-headers) gen-mpn-copy fpioconst.h
+distribute := $(distribute) $(mpn-headers) gen-mpn-copy fpioconst.h \
+             tst-putenvmod.c
+
+tests-extras += tst-putenvmod
+extra-objs += tst-putenvmod.os
 
-generated += isomac isomac.out
+generated += isomac isomac.out tst-putenvmod.so
 
 CFLAGS-bsearch.c = $(uses-callbacks)
 CFLAGS-msort.c = $(uses-callbacks)
@@ -85,8 +94,6 @@ CFLAGS-qsort.c = $(uses-callbacks)
 CFLAGS-system.c = -fexceptions
 CFLAGS-fmtmsg.c = -fexceptions
 
-include ../Makeconfig
-
 ifneq (,$(filter %REENTRANT, $(defines)))
 CFLAGS-strfmon.c = -D_IO_MTSAFE_IO
 CFLAGS-strfmon_l.c = -D_IO_MTSAFE_IO
@@ -124,3 +131,9 @@ $(objpfx)isomac: isomac.c
 
 $(objpfx)tst-fmtmsg.out: tst-fmtmsg.sh $(objpfx)tst-fmtmsg
        $(SHELL) -e $< $(common-objpfx) '$(run-program-prefix)' $(common-objpfx)stdlib/
+
+$(objpfx)tst-putenv: $(objpfx)tst-putenvmod.so
+
+$(objpfx)tst-putenvmod.so: $(objpfx)tst-putenvmod.os
+       $(build-module)
+CFLAGS-tst-putenvmod.c = -DNOT_IN_libc=1
diff --git a/stdlib/tst-putenv.c b/stdlib/tst-putenv.c
new file mode 100644 (file)
index 0000000..47513ea
--- /dev/null
@@ -0,0 +1,18 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+static int
+do_test (void)
+{
+  char *p = getenv ("SOMETHING_NOBODY_USES");
+  if (p == NULL)
+    {
+      puts ("envvar not defined");
+      return 1;
+    }
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/stdlib/tst-putenvmod.c b/stdlib/tst-putenvmod.c
new file mode 100644 (file)
index 0000000..7c0c337
--- /dev/null
@@ -0,0 +1,17 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+void
+__attribute ((constructor))
+init (void)
+{
+  puts ("init DSO");
+
+  static char str[] = "SOMETHING_NOBODY_USES=something_else";
+  if (putenv (str) != 0)
+    {
+      puts ("putenv failed");
+      _exit (1);
+    }
+}
index fc9df40996e334c11c5e05cfc370b29b136f2461..0a8b0ce32ab27f5053558619e5c56a9d316d4603 100644 (file)
@@ -106,9 +106,9 @@ LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL),
 
   __libc_multiple_libcs = &_dl_starting_up && !_dl_starting_up;
 
+#ifndef SHARED
   INIT_ARGV_and_ENVIRON;
 
-#ifndef SHARED
   /* Store the lowest stack address.  This is done in ld.so if this is
      the code for the DSO.  */
   __libc_stack_end = stack_end;