Module Name: src Committed By: matt Date: Fri Feb 28 05:43:49 UTC 2014
Modified Files: src/sys/arch/powerpc/powerpc: powerpc_machdep.c Log Message: 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?) To generate a diff of this commit: cvs rdiff -u -r1.66 -r1.67 src/sys/arch/powerpc/powerpc/powerpc_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/powerpc/powerpc/powerpc_machdep.c diff -u src/sys/arch/powerpc/powerpc/powerpc_machdep.c:1.66 src/sys/arch/powerpc/powerpc/powerpc_machdep.c:1.67 --- src/sys/arch/powerpc/powerpc/powerpc_machdep.c:1.66 Fri Nov 8 04:32:58 2013 +++ src/sys/arch/powerpc/powerpc/powerpc_machdep.c Fri Feb 28 05:43:49 2014 @@ -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 @@ setregs(struct lwp *l, struct exec_packa 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 @@ setregs(struct lwp *l, struct exec_packa 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;