summary refs log tree commit diff
path: root/sysdeps/mach
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>2000-04-02 22:01:23 +0000
committerRoland McGrath <roland@gnu.org>2000-04-02 22:01:23 +0000
commit5879ee9fa107553df828f71fd8e6633d3032370a (patch)
tree184e7f19b623b4ddf26ea256b80e11ec350bc884 /sysdeps/mach
parente1724cd7ef4da860e8a1bfbe8adf0e0ec4d0e90f (diff)
downloadglibc-5879ee9fa107553df828f71fd8e6633d3032370a.tar.gz
glibc-5879ee9fa107553df828f71fd8e6633d3032370a.tar.xz
glibc-5879ee9fa107553df828f71fd8e6633d3032370a.zip
* sysdeps/mach/hurd/i386/init-first.c: Replace PIC #ifdefs with SHARED.
	(init1): Don't initialize __environ here, since init already does it.
	(first_init): New function, broken out of _init.
	(_hurd_stack_setup): Use it.
	[SHARED] (_dl_init_first): New function, renamed from old _init.
	(init1) [SHARED]: Don't call posixland_init here.
	(posixland_init): Take ENVP arg, so signature is usual for initializer.
	[SHARED] (_init): Define as alias for posixland_init.
	[! SHARED] (__libc_first_init): Define as alias for posixland_init.
	* sysdeps/i386/dl-machine.h (RTLD_START): Insert the macro
	RTLD_START_SPECIAL_INIT before calling initializers.
	(RTLD_START_SPECIAL_INIT): Define to empty if undefined.
	* sysdeps/mach/hurd/i386/dl-machine.h: New file.
	* sysdeps/mach/hurd/dl-sysdep.c (_dl_init_first): New weak function.
	* elf/Versions ({libc,ld.so}: GLIBC_2.2): Add _dl_init_first.
Diffstat (limited to 'sysdeps/mach')
-rw-r--r--sysdeps/mach/hurd/dl-sysdep.c6
-rw-r--r--sysdeps/mach/hurd/i386/dl-machine.h7
-rw-r--r--sysdeps/mach/hurd/i386/init-first.c65
3 files changed, 48 insertions, 30 deletions
diff --git a/sysdeps/mach/hurd/dl-sysdep.c b/sysdeps/mach/hurd/dl-sysdep.c
index a1f4565869..9083ca0350 100644
--- a/sysdeps/mach/hurd/dl-sysdep.c
+++ b/sysdeps/mach/hurd/dl-sysdep.c
@@ -730,3 +730,9 @@ _dl_important_hwcaps (const char *platform, size_t platform_len, size_t *sz,
   *sz = 1;
   return result;
 }
+
+void weak_function
+_dl_init_first (int argc, ...)
+{
+  /* This no-op definition only gets used if libc is not linked in.  */
+}
diff --git a/sysdeps/mach/hurd/i386/dl-machine.h b/sysdeps/mach/hurd/i386/dl-machine.h
new file mode 100644
index 0000000000..153abba48f
--- /dev/null
+++ b/sysdeps/mach/hurd/i386/dl-machine.h
@@ -0,0 +1,7 @@
+/* Dynamic linker magic for Hurd/i386.
+   This file just gets us a call to _dl_first_init inserted
+   into the asm in sysdeps/i386/dl-machine.h that contains
+   the initializer code.  */
+
+#define RTLD_START_SPECIAL_INIT "call _dl_init_first@PLT"
+#include_next "dl-machine.h"
diff --git a/sysdeps/mach/hurd/i386/init-first.c b/sysdeps/mach/hurd/i386/init-first.c
index ee7b90252b..505c9ca328 100644
--- a/sysdeps/mach/hurd/i386/init-first.c
+++ b/sysdeps/mach/hurd/i386/init-first.c
@@ -1,5 +1,5 @@
 /* Initialization code run first thing by the ELF startup code.  For i386/Hurd.
-   Copyright (C) 1995, 96, 97, 98, 99 Free Software Foundation, Inc.
+   Copyright (C) 1995,96,97,98,99,2000 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -35,7 +35,7 @@ unsigned int __hurd_threadvar_max;
 unsigned long int __hurd_threadvar_stack_offset;
 unsigned long int __hurd_threadvar_stack_mask;
 
-#ifndef PIC
+#ifndef SHARED
 int __libc_enable_secure;
 #endif
 int __libc_multiple_libcs = 1;
@@ -53,8 +53,8 @@ DEFINE_HOOK (_hurd_preinit_hook, (void));
 
 /* We call this once the Hurd magic is all set up and we are ready to be a
    Posixoid program.  This does the same things the generic version does.  */
-static void internal_function
-posixland_init (int argc, char **argv)
+static void
+posixland_init (int argc, char **argv, char **envp)
 {
   __libc_init (argc, argv, __environ);
 
@@ -76,7 +76,6 @@ init1 (int argc, char *arg0, ...)
 
   __libc_argc = argc;
   __libc_argv = argv;
-  __environ = envp;
 
   while (*envp)
     ++envp;
@@ -111,10 +110,8 @@ init1 (int argc, char *arg0, ...)
 		d->portarray, d->portarraysize,
 		d->intarray, d->intarraysize);
 
-#ifndef PIC
+#ifndef SHARED
   __libc_enable_secure = d->flags & EXEC_SECURE;
-#else
-  posixland_init(argc, argv);
 #endif
 }
 
@@ -247,38 +244,49 @@ asm ("
 ");
 
 
-#ifdef PIC
-/* 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, ...)
+/* Do the first essential initializations that must precede all else.  */
+static inline void
+first_init (void)
 {
   /* Initialize data structures so we can do RPCs.  */
   __mach_init ();
 
   RUN_HOOK (_hurd_preinit_hook, ());
+}
+
+#ifdef SHARED
+/* This function is called specially by the dynamic linker to do early
+   initialization of the shared C library before normal initializers
+   expecting a Posixoid environment can run.  It gets called with the
+   stack set up just as the user will see it, so it can switch stacks.  */
+
+void
+_dl_init_first (int argc, ...)
+{
+  first_init ();
 
   init (&argc);
 }
 #endif
 
 
+#ifdef SHARED
+/* The regular posixland initialization is what goes into libc's
+   normal initializer.  */
+/* 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!!  */
+strong_alias (posixland_init, _init);
+
 void
 __libc_init_first (int argc, char **argv, char **envp)
-#ifdef PIC
 {
   /* Everything was done in the shared library initializer, _init.  */
 }
 #else
-{
-  posixland_init(argc, argv);
-}
+strong_alias (posixland_init, __libc_init_first);
+
 
 /* XXX This is all a crock and I am not happy with it.
    This poorly-named function is called by static-start.S,
@@ -295,9 +303,9 @@ _hurd_stack_setup (int argc __attribute__ ((unused)), ...)
 	}
 
       /* Push the user return address after the argument data, and then
-	 jump to `doinit1' (above), so it is as if __libc_init_first's
-	 caller had called `doinit1' with the argument data already on the
-      stack.  */
+         jump to `doinit1' (above), so it is as if __libc_init_first's
+         caller had called `doinit1' with the argument data already on the
+         stack.  */
       *--data = (&argc)[-1];
       asm volatile ("movl %0, %%esp\n" /* Switch to new outermost stack.  */
 		    "movl $0, %%ebp\n" /* Clear outermost frame pointer.  */
@@ -305,10 +313,7 @@ _hurd_stack_setup (int argc __attribute__ ((unused)), ...)
       /* NOTREACHED */
     }
 
-  /* Initialize data structures so we can do RPCs.  */
-  __mach_init ();
-
-  RUN_HOOK (_hurd_preinit_hook, ());
+  first_init ();
 
   _hurd_startup ((void **) &argc, &doinit);
 }