Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys deduplicate the elf auxv builder code, welcome to 8.99.43
details: https://anonhg.NetBSD.org/src/rev/43934e0ecd0c
branches: trunk
changeset: 451854:43934e0ecd0c
user: christos <christos%NetBSD.org@localhost>
date: Fri Jun 07 23:35:52 2019 +0000
description:
deduplicate the elf auxv builder code, welcome to 8.99.43
diffstat:
sys/compat/netbsd32/netbsd32_exec_elf32.c | 98 +------------------------------
sys/kern/exec_elf.c | 32 ++++++---
sys/sys/exec_elf.h | 4 +-
sys/sys/param.h | 4 +-
4 files changed, 29 insertions(+), 109 deletions(-)
diffs (239 lines):
diff -r 84963b63fa98 -r 43934e0ecd0c sys/compat/netbsd32/netbsd32_exec_elf32.c
--- a/sys/compat/netbsd32/netbsd32_exec_elf32.c Fri Jun 07 21:32:34 2019 +0000
+++ b/sys/compat/netbsd32/netbsd32_exec_elf32.c Fri Jun 07 23:35:52 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: netbsd32_exec_elf32.c,v 1.44 2019/06/07 20:13:54 christos Exp $ */
+/* $NetBSD: netbsd32_exec_elf32.c,v 1.45 2019/06/07 23:35:53 christos Exp $ */
/* from: NetBSD: exec_aout.c,v 1.15 1996/09/26 23:34:46 cgd Exp */
/*
@@ -57,7 +57,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_exec_elf32.c,v 1.44 2019/06/07 20:13:54 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_exec_elf32.c,v 1.45 2019/06/07 23:35:53 christos Exp $");
#define ELFSIZE 32
@@ -134,102 +134,10 @@
netbsd32_elf32_copyargs(struct lwp *l, struct exec_package *pack,
struct ps_strings *arginfo, char **stackp, void *argp)
{
- size_t len, vlen;
- AuxInfo ai[ELF_AUX_ENTRIES], *a, *execname;
- struct elf_args *ap;
int error;
if ((error = netbsd32_copyargs(l, pack, arginfo, stackp, argp)) != 0)
return error;
- a = ai;
-
- memset(ai, 0, sizeof(ai));
-
- /*
- * Push extra arguments on the stack needed by dynamically
- * linked binaries
- */
- if ((ap = (struct elf_args *)pack->ep_emul_arg)) {
-
- a->a_type = AT_PHDR;
- a->a_v = ap->arg_phaddr;
- a++;
-
- a->a_type = AT_PHENT;
- a->a_v = ap->arg_phentsize;
- a++;
-
- a->a_type = AT_PHNUM;
- a->a_v = ap->arg_phnum;
- a++;
-
- a->a_type = AT_PAGESZ;
- a->a_v = PAGE_SIZE;
- a++;
-
- a->a_type = AT_BASE;
- a->a_v = ap->arg_interp;
- a++;
-
- a->a_type = AT_FLAGS;
- a->a_v = 0;
- a++;
-
- a->a_type = AT_ENTRY;
- a->a_v = ap->arg_entry;
- a++;
-
- a->a_type = AT_EUID;
- a->a_v = kauth_cred_geteuid(l->l_cred);
- a++;
-
- a->a_type = AT_RUID;
- a->a_v = kauth_cred_getuid(l->l_cred);
- a++;
-
- a->a_type = AT_EGID;
- a->a_v = kauth_cred_getegid(l->l_cred);
- a++;
-
- a->a_type = AT_RGID;
- a->a_v = kauth_cred_getgid(l->l_cred);
- a++;
-
- a->a_type = AT_STACKBASE;
- a->a_v = l->l_proc->p_stackbase;
- a++;
-
- execname = a;
- a->a_type = AT_SUN_EXECNAME;
- a++;
-
- exec_free_emul_arg(pack);
- } else {
- execname = NULL;
- }
-
- a->a_type = AT_NULL;
- a->a_v = 0;
- a++;
-
- vlen = (a - ai) * sizeof(ai[0]);
-
- KASSERT(vlen <= sizeof(ai));
-
- if (execname) {
- char *path = l->l_proc->p_path;
- execname->a_v = (uintptr_t)(*stackp + vlen);
- len = strlen(path) + 1;
- if ((error = copyout(path, (*stackp + vlen), len)) != 0)
- return error;
- len = ALIGN(len);
- } else {
- len = 0;
- }
- if ((error = copyout(ai, *stackp, len)) != 0)
- return error;
- *stackp += vlen + len;
-
- return 0;
+ return elf32_populate_auxv(l, pack, stackp);
}
diff -r 84963b63fa98 -r 43934e0ecd0c sys/kern/exec_elf.c
--- a/sys/kern/exec_elf.c Fri Jun 07 21:32:34 2019 +0000
+++ b/sys/kern/exec_elf.c Fri Jun 07 23:35:52 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: exec_elf.c,v 1.97 2018/04/12 20:49:08 christos Exp $ */
+/* $NetBSD: exec_elf.c,v 1.98 2019/06/07 23:35:52 christos Exp $ */
/*-
* Copyright (c) 1994, 2000, 2005, 2015 The NetBSD Foundation, Inc.
@@ -57,7 +57,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: exec_elf.c,v 1.97 2018/04/12 20:49:08 christos Exp $");
+__KERNEL_RCSID(1, "$NetBSD: exec_elf.c,v 1.98 2019/06/07 23:35:52 christos Exp $");
#ifdef _KERNEL_OPT
#include "opt_pax.h"
@@ -89,6 +89,7 @@
#define elf_check_header ELFNAME(check_header)
#define elf_copyargs ELFNAME(copyargs)
+#define elf_populate_auxv ELFNAME(populate_auxv)
#define elf_load_interp ELFNAME(load_interp)
#define elf_load_psection ELFNAME(load_psection)
#define exec_elf_makecmds ELFNAME2(exec,makecmds)
@@ -149,22 +150,15 @@
return 0;
}
-/*
- * Copy arguments onto the stack in the normal way, but add some
- * extra information in case of dynamic binding.
- */
+
int
-elf_copyargs(struct lwp *l, struct exec_package *pack,
- struct ps_strings *arginfo, char **stackp, void *argp)
+elf_populate_auxv(struct lwp *l, struct exec_package *pack, char **stackp)
{
size_t len, vlen;
AuxInfo ai[ELF_AUX_ENTRIES], *a, *execname;
struct elf_args *ap;
int error;
- if ((error = copyargs(l, pack, arginfo, stackp, argp)) != 0)
- return error;
-
a = ai;
memset(ai, 0, sizeof(ai));
@@ -266,6 +260,22 @@
}
/*
+ * Copy arguments onto the stack in the normal way, but add some
+ * extra information in case of dynamic binding.
+ */
+int
+elf_copyargs(struct lwp *l, struct exec_package *pack,
+ struct ps_strings *arginfo, char **stackp, void *argp)
+{
+ int error;
+
+ if ((error = copyargs(l, pack, arginfo, stackp, argp)) != 0)
+ return error;
+
+ return elf_populate_auxv(l, pack, stackp);
+}
+
+/*
* elf_check_header():
*
* Check header for validity; return 0 if ok, ENOEXEC if error
diff -r 84963b63fa98 -r 43934e0ecd0c sys/sys/exec_elf.h
--- a/sys/sys/exec_elf.h Fri Jun 07 21:32:34 2019 +0000
+++ b/sys/sys/exec_elf.h Fri Jun 07 23:35:52 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: exec_elf.h,v 1.160 2018/05/24 17:05:18 christos Exp $ */
+/* $NetBSD: exec_elf.h,v 1.161 2019/06/07 23:35:52 christos Exp $ */
/*-
* Copyright (c) 1994 The NetBSD Foundation, Inc.
@@ -1341,6 +1341,7 @@
#ifdef EXEC_ELF32
int exec_elf32_makecmds(struct lwp *, struct exec_package *);
+int elf32_populate_auxv(struct lwp *, struct exec_package *, char **);
int elf32_copyargs(struct lwp *, struct exec_package *,
struct ps_strings *, char **, void *);
@@ -1353,6 +1354,7 @@
#ifdef EXEC_ELF64
int exec_elf64_makecmds(struct lwp *, struct exec_package *);
+int elf64_populate_auxv(struct lwp *, struct exec_package *, char **);
int elf64_copyargs(struct lwp *, struct exec_package *,
struct ps_strings *, char **, void *);
diff -r 84963b63fa98 -r 43934e0ecd0c sys/sys/param.h
--- a/sys/sys/param.h Fri Jun 07 21:32:34 2019 +0000
+++ b/sys/sys/param.h Fri Jun 07 23:35:52 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: param.h,v 1.590 2019/05/29 10:09:01 msaitoh Exp $ */
+/* $NetBSD: param.h,v 1.591 2019/06/07 23:35:52 christos Exp $ */
/*-
* Copyright (c) 1982, 1986, 1989, 1993
@@ -67,7 +67,7 @@
* 2.99.9 (299000900)
*/
-#define __NetBSD_Version__ 899004200 /* NetBSD 8.99.42 */
+#define __NetBSD_Version__ 899004300 /* NetBSD 8.99.43 */
#define __NetBSD_Prereq__(M,m,p) (((((M) * 100000000) + \
(m) * 1000000) + (p) * 100) <= __NetBSD_Version__)
Home |
Main Index |
Thread Index |
Old Index