[patch] Adjust AT_EXECFN on explicit loader invocation
Paul Pluzhnikov
ppluzhnikov@google.com
Wed Nov 13 21:03:00 GMT 2013
On Mon, Nov 4, 2013 at 10:40 AM, Adhemerval Zanella
<azanella@linux.vnet.ibm.com> wrote:
> I think it would be good if you integrate the attached testcase as a real one.
Done.
Thanks,
--
Paul Pluzhnikov
2013-11-13 Paul Pluzhnikov <ppluzhnikov@google.com>
* elf/Makefile (tst-auxv): New test.
* elf/tst-auxv.c: New
* elf/rtld.c (dl_main): Adjust AT_EXECFN
-------------- next part --------------
diff --git a/elf/Makefile b/elf/Makefile
index 27d249b..c6626e1 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -119,7 +119,8 @@ $(inst_auditdir)/sotruss-lib.so: $(objpfx)sotruss-lib.so $(+force)
endif
tests = tst-tls1 tst-tls2 tst-tls9 tst-leaks1 \
- tst-array1 tst-array2 tst-array3 tst-array4 tst-array5
+ tst-array1 tst-array2 tst-array3 tst-array4 tst-array5 \
+ tst-auxv
tests-static = tst-tls1-static tst-tls2-static tst-stackguard1-static \
tst-leaks1-static tst-array1-static tst-array5-static \
tst-ptrguard1-static
diff --git a/elf/rtld.c b/elf/rtld.c
index c5a6538..3d207a3 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -1118,6 +1118,9 @@ of this helper program; chances are you did not intend to run this program.\n\
case AT_ENTRY:
av->a_un.a_val = *user_entry;
break;
+ case AT_EXECFN:
+ av->a_un.a_val = (uintptr_t) _dl_argv[0];
+ break;
}
#endif
}
diff --git a/elf/tst-auxv.c b/elf/tst-auxv.c
new file mode 100644
index 0000000..f9701c7
--- /dev/null
+++ b/elf/tst-auxv.c
@@ -0,0 +1,62 @@
+/* Copyright (C) 2013 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
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ 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, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <elf.h>
+#include <link.h>
+#include <string.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <ldsodefs.h> /* For HAVE_AUX_VECTOR */
+
+#ifdef HAVE_AUX_VECTOR
+
+static int
+do_test (int argc, char *argv[])
+{
+# if _STACK_GROWS_DOWN
+ const int incr = 1;
+# else
+ const int incr = -1;
+# endif
+
+ char **e = __environ;
+ ElfW (auxv_t) *aux;
+
+ for (; *e != NULL; e += incr)
+ ;
+
+ for (aux = (ElfW (auxv_t) *) (e + incr); aux->a_type != AT_NULL; aux += incr)
+ if (aux->a_type == AT_EXECFN)
+ {
+ return strcmp (argv[0], (char *) aux->a_un.a_val) ? 1 : 0;
+ }
+
+ fprintf (stderr, "did not find AT_EXECFN in auxv[]\n");
+ return 1;
+}
+
+#else /* HAVE_AUX_VECTOR */
+
+static int
+do_test(int argc, char *argv[])
+{
+ return 0;
+}
+
+#endif /* HAVE_AUX_VECTOR */
+
+#include "../test-skeleton.c"
More information about the Libc-alpha
mailing list