This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[HURD PATCH 6/7] Propagate _hurd_init_filename beyond dynamic loading


This is not strictly required to support $ORIGIN in RPATH, but the principle
of least surprise would compel us not to leave a blanked out
_hurd_init_filename after the dynamic loading phase.

	* hurd/hurdstartup.h (hurd_startup_data): Add a filename field.
	* hurd/hurdstartup.c (_hurd_startup): Fetch the filename into the
	hurd_startup_data, then copy into _hurd_init_filename.
	* sysdeps/mach/hurd/i386/init-first.c (init1): Copy from the
	hurd_startup_data into _hurd_init_filename.
	* sysdeps/mach/hurd/powerpc/init-first.c (init1): Likewise.
---
 hurd/hurdstartup.c                     |    9 +++++----
 hurd/hurdstartup.h                     |    2 ++
 sysdeps/mach/hurd/i386/init-first.c    |    1 +
 sysdeps/mach/hurd/powerpc/init-first.c |    1 +
 4 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/hurd/hurdstartup.c b/hurd/hurdstartup.c
index 577886d..e92dd08 100644
--- a/hurd/hurdstartup.c
+++ b/hurd/hurdstartup.c
@@ -83,34 +83,34 @@ _hurd_startup (void **argptr, void (*main) (intptr_t *data))
     {
       /* Call the exec server on our bootstrap port and
 	 get all our standard information from it.  */
 
       argslen = envlen = 0;
       data.dtablesize = data.portarraysize = data.intarraysize = 0;
 
       err = __exec_startup_get_info_2 (in_bootstrap,
 				     &data.user_entry,
 				     &data.phdr, &data.phdrsz,
 				     &data.stack_base, &data.stack_size,
 				     &data.flags,
-				     _hurd_init_filename,
+				     data.filename,
 				     &args, &argslen,
 				     &env, &envlen,
 				     &data.dtable, &data.dtablesize,
 				     &data.portarray, &data.portarraysize,
 				     &data.intarray, &data.intarraysize);
 
-      /* Clear _hurd_init_filename if it's too long, or if we failed.  */
-      if (err || _hurd_init_filename[sizeof (string_t) - 1])
-	memset (_hurd_init_filename, 0, sizeof (string_t));
+      /* Clear the filename if it's too long, or if we failed.  */
+      if (err || data.filename[sizeof (string_t) - 1])
+	memset (data.filename, 0, sizeof (string_t));
 
       /* Fall back to the legacy version.  */
       if (err == MIG_BAD_ID)
 	{
 	  err = __exec_startup_get_info (in_bootstrap,
 					 &data.user_entry,
 					 &data.phdr, &data.phdrsz,
 					 &data.stack_base, &data.stack_size,
 					 &data.flags,
 					 &args, &argslen,
 					 &env, &envlen,
 					 &data.dtable, &data.dtablesize,
@@ -197,21 +197,22 @@ _hurd_startup (void **argptr, void (*main) (intptr_t *data))
       argv = args->argv;
       envp = args->envp;
     }
 
   {
     struct hurd_startup_data *d = (void *) &envp[envc + 1];
 
     if ((void *) d != argv[0])
       {
 	*d = data;
 	_hurd_init_dtable = d->dtable;
 	_hurd_init_dtablesize = d->dtablesize;
+	memcpy (_hurd_init_filename, d->filename, sizeof (string_t));
       }
 
     (*main) (argcptr);
   }
 
   /* Should never get here.  */
   LOSE;
   abort ();
 }
diff --git a/hurd/hurdstartup.h b/hurd/hurdstartup.h
index e527668..09d0af1 100644
--- a/hurd/hurdstartup.h
+++ b/hurd/hurdstartup.h
@@ -12,24 +12,25 @@
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
    License along with the GNU C Library; if not, write to the Free
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA.  */
 
 #ifndef _HURDSTARTUP_H
 #define _HURDSTARTUP_H 1
 
 # include <stdint.h>
+# include <hurd/hurd_types.h>
 
 /* Interesting data saved from the exec_startup reply.
    The DATA argument to *MAIN (see below) points to:
 
     int argc;
     char *argv[argc];
     char *argv_terminator = NULL;
     char *envp[?];
     char *envp_terminator = NULL;
     struct hurd_startup_data data;
 
 */
@@ -39,24 +40,25 @@ struct hurd_startup_data
     int flags;
     mach_port_t *dtable;
     mach_msg_type_number_t dtablesize;
     mach_port_t *portarray;
     mach_msg_type_number_t portarraysize;
     int *intarray;
     mach_msg_type_number_t intarraysize;
     vm_address_t stack_base;
     vm_size_t stack_size;
     vm_address_t phdr;
     vm_size_t phdrsz;
     vm_address_t user_entry;
+    string_t filename;
   };
 
 
 /* Initialize Mach RPCs; do initial handshake with the exec server (or
    extract the arguments from the stack in the case of the bootstrap task);
    finally, call *MAIN with the information gleaned.  That function is not
    expected to return.  ARGPTR should be the address of the first argument
    of the entry point function that is called with the stack exactly as the
    exec server or kernel sets it.  */
 
 extern void _hurd_startup (void **argptr, void (*main) (intptr_t *data));
 
diff --git a/sysdeps/mach/hurd/i386/init-first.c b/sysdeps/mach/hurd/i386/init-first.c
index 60823bd..1281156 100644
--- a/sysdeps/mach/hurd/i386/init-first.c
+++ b/sysdeps/mach/hurd/i386/init-first.c
@@ -132,24 +132,25 @@ init1 (int argc, char *arg0, ...)
     }
 
 #ifndef SHARED
   __libc_enable_secure = d->flags & EXEC_SECURE;
 
   _dl_phdr = (ElfW(Phdr) *) d->phdr;
   _dl_phnum = d->phdrsz / sizeof (ElfW(Phdr));
   assert (d->phdrsz % sizeof (ElfW(Phdr)) == 0);
 #endif
 
   _hurd_init_dtable = d->dtable;
   _hurd_init_dtablesize = d->dtablesize;
+  memcpy (_hurd_init_filename, d->filename, sizeof (string_t));
 
   {
     /* Check if the stack we are now on is different from
        the one described by _hurd_stack_{base,size}.  */
 
     char dummy;
     const vm_address_t newsp = (vm_address_t) &dummy;
 
     if (d->stack_size != 0 && (newsp < d->stack_base ||
 			       newsp - d->stack_base > d->stack_size))
       /* The new stack pointer does not intersect with the
 	 stack the exec server set up for us, so free that stack.  */
diff --git a/sysdeps/mach/hurd/powerpc/init-first.c b/sysdeps/mach/hurd/powerpc/init-first.c
index 21b5054..080748c 100644
--- a/sysdeps/mach/hurd/powerpc/init-first.c
+++ b/sysdeps/mach/hurd/powerpc/init-first.c
@@ -101,24 +101,25 @@ init1 (int *data)
   d = (void *) ++envp;
 
   /* If we are the bootstrap task started by the kernel,
      then after the environment pointers there is no Hurd
      data block; the argument strings start there.  */
   /* OSF Mach starts the bootstrap task with argc == 0.
      XXX This fails if a non-bootstrap task gets started
      with argc == 0.  */
   if (argc && (void *) d != argv[0])
     {
       _hurd_init_dtable = d->dtable;
       _hurd_init_dtablesize = d->dtablesize;
+      memcpy (_hurd_init_filename, d->filename, sizeof (string_t));
 
 #if 0  /* We can't free the old stack because it contains the argument strings.  */
       {
 	/* Check if the stack we are now on is different from
 	   the one described by _hurd_stack_{base,size}.  */
 
 	char dummy;
 	const vm_address_t newsp = (vm_address_t) &dummy;
 
 	if (d->stack_size != 0 && (newsp < d->stack_base ||
 				   newsp - d->stack_base > d->stack_size))
 	  /* The new stack pointer does not intersect with the
-- 
1.7.5.4


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]