Module Name: src
Committed By: joerg
Date: Sat Feb 4 18:12:03 UTC 2012
Modified Files:
src/sys/kern: exec_elf.c
src/sys/sys: exec_elf.h
Log Message:
Add AuxInfo record with the base address of the main thread.
To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/sys/kern/exec_elf.c
cvs rdiff -u -r1.121 -r1.122 src/sys/sys/exec_elf.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/kern/exec_elf.c
diff -u src/sys/kern/exec_elf.c:1.35 src/sys/kern/exec_elf.c:1.36
--- src/sys/kern/exec_elf.c:1.35 Fri Feb 3 20:11:54 2012
+++ src/sys/kern/exec_elf.c Sat Feb 4 18:12:02 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: exec_elf.c,v 1.35 2012/02/03 20:11:54 matt Exp $ */
+/* $NetBSD: exec_elf.c,v 1.36 2012/02/04 18:12:02 joerg Exp $ */
/*-
* Copyright (c) 1994, 2000, 2005 The NetBSD Foundation, Inc.
@@ -57,7 +57,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: exec_elf.c,v 1.35 2012/02/03 20:11:54 matt Exp $");
+__KERNEL_RCSID(1, "$NetBSD: exec_elf.c,v 1.36 2012/02/04 18:12:02 joerg Exp $");
#ifdef _KERNEL_OPT
#include "opt_pax.h"
@@ -238,6 +238,10 @@ elf_copyargs(struct lwp *l, struct exec_
a->a_v = kauth_cred_getgid(l->l_cred);
a++;
+ a->a_type = AT_STACKBASE;
+ a->a_v = l->l_proc->p_stackbase;
+ a++;
+
if (pack->ep_path) {
execname = a;
a->a_type = AT_SUN_EXECNAME;
@@ -251,7 +255,9 @@ elf_copyargs(struct lwp *l, struct exec_
a->a_v = 0;
a++;
- vlen = (a - ai) * sizeof(AuxInfo);
+ vlen = (a - ai) * sizeof(ai[0]);
+
+ KASSERT(vlen <= sizeof(ai));
if (execname) {
char *path = pack->ep_path;
Index: src/sys/sys/exec_elf.h
diff -u src/sys/sys/exec_elf.h:1.121 src/sys/sys/exec_elf.h:1.122
--- src/sys/sys/exec_elf.h:1.121 Sat Jan 21 21:44:03 2012
+++ src/sys/sys/exec_elf.h Sat Feb 4 18:12:02 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: exec_elf.h,v 1.121 2012/01/21 21:44:03 njoly Exp $ */
+/* $NetBSD: exec_elf.h,v 1.122 2012/02/04 18:12:02 joerg Exp $ */
/*-
* Copyright (c) 1994 The NetBSD Foundation, Inc.
@@ -714,6 +714,7 @@ typedef struct {
#define AT_DCACHEBSIZE 10 /* Data cache block size */
#define AT_ICACHEBSIZE 11 /* Instruction cache block size */
#define AT_UCACHEBSIZE 12 /* Unified cache block size */
+#define AT_STACKBASE 13 /* Base address of the main thread */
/* Vendor specific */
#define AT_MIPS_NOTELF 10 /* XXX a_val != 0 -> MIPS XCOFF executable */
@@ -1138,7 +1139,7 @@ typedef Elf32_Versym Elf64_Versym;
#ifdef _KERNEL
-#define ELF_AUX_ENTRIES 14 /* Max size of aux array passed to loader */
+#define ELF_AUX_ENTRIES 15 /* Max size of aux array passed to loader */
#define ELF32_NO_ADDR (~(Elf32_Addr)0) /* Indicates addr. not yet filled in */
#define ELF32_LINK_ADDR ((Elf32_Addr)-2) /* advises to use link address */
#define ELF64_NO_ADDR (~(Elf64_Addr)0) /* Indicates addr. not yet filled in */