tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Support for passing down the stack base to userland
Hi all,
the attached patch passes down the stack base addresses of the main
thread. This is the final kernel change required to remove the stackid
logic in libpthread. This is for use by pthread_attr_getstack as needed
e.g. by a number of programs using garbage collection.
Joerg
Index: kern/exec_elf.c
===================================================================
RCS file: /home/joerg/repo/netbsd/src/sys/kern/exec_elf.c,v
retrieving revision 1.34
diff -u -p -r1.34 exec_elf.c
--- kern/exec_elf.c 1 Feb 2012 21:49:52 -0000 1.34
+++ kern/exec_elf.c 3 Feb 2012 20:27:04 -0000
@@ -235,6 +235,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;
@@ -249,7 +253,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: sys/exec_elf.h
===================================================================
RCS file: /home/joerg/repo/netbsd/src/sys/sys/exec_elf.h,v
retrieving revision 1.121
diff -u -p -r1.121 exec_elf.h
--- sys/exec_elf.h 21 Jan 2012 21:44:03 -0000 1.121
+++ sys/exec_elf.h 3 Feb 2012 20:25:25 -0000
@@ -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 */
Home |
Main Index |
Thread Index |
Old Index