[PATCH] ld.so: Adjust the auxv if ld.so is directly invoked
Thomas Schwinge
thomas@schwinge.name
Mon Mar 29 22:50:00 GMT 2010
Hello!
On Fri, Mar 26, 2010 at 02:55:23PM -0700, Ulrich Drepper wrote:
> On 03/26/2010 12:15 PM, Thomas Schwinge wrote:
> > Would the glibc maintainers rather have me send a patch (a) for
> > conditionalizing all auxv code on that conditional, or (b) have the
> > generic code cope with auxv == NULL?
>
> Nothing which has runtime overhead on Linux is acceptable. If this can
> be achieved using macros it's likely a bit better.
Here is a patch; a most pragmatic one, taking into account that we might
decide to also support auxvs on the Hurd in the future.
Reaction to 3a56ea26730755076cb5bc1d07727c7a4fcb8fd7.
Conditionalize auxv code; Hurd auxv changes.
2010-03-28 Thomas Schwinge <thomas@schwinge.name>
* sysdeps/mach/hurd/dl-sysdep.c (_dl_sysdep_start): Adapt to auxv
changes in the generic code.
* elf/rtld.c (dl_main): Conditionalize the code that dereferences auxv
to [HAVE_AUX_VECTOR].
elf/rtld.c | 4 ++++
sysdeps/mach/hurd/dl-sysdep.c | 8 ++++----
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/elf/rtld.c b/elf/rtld.c
index 3afb997..b1899f6 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -928,7 +928,9 @@ dl_main (const ElfW(Phdr) *phdr,
if (*user_entry == (ElfW(Addr)) ENTRY_POINT)
{
+#ifdef HAVE_AUX_VECTOR
ElfW(auxv_t) *av;
+#endif
/* Ho ho. We are not the program interpreter! We are the program
itself! This means someone ran ld.so as a command. Well, that
@@ -1086,6 +1088,7 @@ of this helper program; chances are you did not intend to run this program.\n\
main_map->l_name = (char *) "";
*user_entry = main_map->l_entry;
+#ifdef HAVE_AUX_VECTOR
/* Adjust the on-stack auxiliary vector so that it looks like the
binary was executed directly. */
for (av = auxv; av->a_type != AT_NULL; av++)
@@ -1101,6 +1104,7 @@ of this helper program; chances are you did not intend to run this program.\n\
av->a_un.a_val = *user_entry;
break;
}
+#endif
}
else
{
diff --git a/sysdeps/mach/hurd/dl-sysdep.c b/sysdeps/mach/hurd/dl-sysdep.c
index 2440682..40323a9 100644
--- a/sysdeps/mach/hurd/dl-sysdep.c
+++ b/sysdeps/mach/hurd/dl-sysdep.c
@@ -1,6 +1,6 @@
/* Operating system support for run-time dynamic linker. Hurd version.
- Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003,2004
- Free Software Foundation, Inc.
+ Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
+ 2010 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
@@ -116,7 +116,7 @@ static void fmh(void) {
ElfW(Addr)
_dl_sysdep_start (void **start_argptr,
void (*dl_main) (const ElfW(Phdr) *phdr, ElfW(Word) phent,
- ElfW(Addr) *user_entry))
+ ElfW(Addr) *user_entry, ElfW(auxv_t) *auxv))
{
void go (intptr_t *argdata)
{
@@ -197,7 +197,7 @@ unfmh(); /* XXX */
up and leave us to transfer control to USER_ENTRY. */
(*dl_main) ((const ElfW(Phdr) *) _dl_hurd_data->phdr,
_dl_hurd_data->phdrsz / sizeof (ElfW(Phdr)),
- &_dl_hurd_data->user_entry);
+ &_dl_hurd_data->user_entry, NULL);
/* The call above might screw a few things up.
--
tg: (62f8db6..) t/ld.so_auxv (depends on: baseline)
Regards,
Thomas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20100329/64669c30/attachment.sig>
More information about the Libc-alpha
mailing list