Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/powerpc/powerpc If execing a LP64 image, we need to...
details: https://anonhg.NetBSD.org/src/rev/5714d7254c26
branches: trunk
changeset: 327148:5714d7254c26
user: matt <matt%NetBSD.org@localhost>
date: Fri Feb 28 05:43:49 2014 +0000
description:
If execing a LP64 image, we need to read the function descriptor to get
the entry point and the TOC base. (Do we need to fixup the TOC base?)
diffstat:
sys/arch/powerpc/powerpc/powerpc_machdep.c | 20 +++++++++++++++++---
1 files changed, 17 insertions(+), 3 deletions(-)
diffs (48 lines):
diff -r 6548c838ed3f -r 5714d7254c26 sys/arch/powerpc/powerpc/powerpc_machdep.c
--- a/sys/arch/powerpc/powerpc/powerpc_machdep.c Fri Feb 28 05:41:59 2014 +0000
+++ b/sys/arch/powerpc/powerpc/powerpc_machdep.c Fri Feb 28 05:43:49 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: powerpc_machdep.c,v 1.66 2013/11/08 04:32:58 nisimura Exp $ */
+/* $NetBSD: powerpc_machdep.c,v 1.67 2014/02/28 05:43:49 matt Exp $ */
/*
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: powerpc_machdep.c,v 1.66 2013/11/08 04:32:58 nisimura Exp $");
+__KERNEL_RCSID(0, "$NetBSD: powerpc_machdep.c,v 1.67 2014/02/28 05:43:49 matt Exp $");
#include "opt_altivec.h"
#include "opt_modular.h"
@@ -103,6 +103,7 @@
struct trapframe * const tf = l->l_md.md_utf;
struct pcb * const pcb = lwp_getpcb(l);
struct ps_strings arginfo;
+ vaddr_t func = pack->ep_entry;
memset(tf, 0, sizeof *tf);
tf->tf_fixreg[1] = -roundup(-stack + 8, 16);
@@ -134,7 +135,20 @@
tf->tf_fixreg[7] = 0; /* termination vector */
tf->tf_fixreg[8] = p->p_psstrp; /* NetBSD extension */
- tf->tf_srr0 = pack->ep_entry;
+#ifdef _LP64
+ if (l->l_proc->p_emul == &emul_netbsd) {
+ /*
+ * For native ELF64, entry point to the function
+ * descriptor which contains the real function address
+ * and its TOC base address.
+ */
+ uintptr_t fdesc[3] = { [0] = func, [1] = 0, [2] = 0 };
+ copyin((void *)func, fdesc, sizeof(fdesc));
+ tf->tf_fixreg[2] = fdesc[1];
+ func = fdesc[0];
+ }
+#endif
+ tf->tf_srr0 = func;
tf->tf_srr1 = PSL_MBO | PSL_USERSET;
#ifdef ALTIVEC
tf->tf_vrsave = 0;
Home |
Main Index |
Thread Index |
Old Index