Restore support for executing BSD/OS binaries on the i386 by passing

the address of the ps_strings structure to the process via %ebx.
For other kinds of binaries, %ebx is still zeroed as before.

Submitted by:	Thomas Stephens <tas@stephens.org>
Reviewed by:	jdp
This commit is contained in:
John Polstra 1999-04-03 22:20:03 +00:00
parent 90aba8be4e
commit 4fe88fe637
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=45270
12 changed files with 38 additions and 22 deletions

View File

@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: machdep.c,v 1.33 1999/02/27 18:41:40 dfr Exp $
* $Id: machdep.c,v 1.34 1999/03/06 04:46:10 wollman Exp $
*/
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -1508,7 +1508,7 @@ cpu_halt(void)
* Clear registers on exec
*/
void
setregs(struct proc *p, u_long entry, u_long stack)
setregs(struct proc *p, u_long entry, u_long stack, u_long ps_strings)
{
struct trapframe *tfp = p->p_md.md_tf;

View File

@ -1,4 +1,4 @@
/* $Id: reg.h,v 1.1.1.1 1998/03/09 05:43:16 jb Exp $ */
/* $Id: reg.h,v 1.2 1998/06/10 10:55:26 dfr Exp $ */
/* From: NetBSD: reg.h,v 1.3 1997/04/06 08:47:40 cgd Exp */
/*
@ -94,7 +94,7 @@ struct fpreg {
#ifdef KERNEL
void restorefpstate __P((struct fpreg *));
void savefpstate __P((struct fpreg *));
void setregs __P((struct proc *, u_long, u_long));
void setregs __P((struct proc *, u_long, u_long, u_long));
#endif
#endif /* _ALPHA_REG_H_ */

View File

@ -35,7 +35,7 @@
* SUCH DAMAGE.
*
* from: @(#)machdep.c 7.4 (Berkeley) 6/3/91
* $Id: machdep.c,v 1.326 1999/02/13 17:45:15 bde Exp $
* $Id: machdep.c,v 1.327 1999/03/06 04:46:18 wollman Exp $
*/
#include "apm.h"
@ -806,10 +806,11 @@ cpu_halt(void)
* Clear registers on exec
*/
void
setregs(p, entry, stack)
setregs(p, entry, stack, ps_strings)
struct proc *p;
u_long entry;
u_long stack;
u_long ps_strings;
{
struct trapframe *regs = p->p_md.md_regs;
struct pcb *pcb = &p->p_addr->u_pcb;
@ -836,6 +837,9 @@ setregs(p, entry, stack)
regs->tf_es = _udatasel;
regs->tf_cs = _ucodesel;
/* PS_STRINGS value for BSD/OS binaries. It is 0 for non-BSD/OS. */
regs->tf_ebx = ps_strings;
/* reset %fs and %gs as well */
pcb->pcb_fs = _udatasel;
pcb->pcb_gs = _udatasel;

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* from: @(#)reg.h 5.5 (Berkeley) 1/18/91
* $Id: reg.h,v 1.15 1997/06/07 04:36:06 bde Exp $
* $Id: reg.h,v 1.16 1998/09/14 22:43:40 jdp Exp $
*/
#ifndef _MACHINE_REG_H_
@ -124,7 +124,7 @@ struct fpreg {
*/
int set_fpregs __P((struct proc *, struct fpreg *));
int set_regs __P((struct proc *p, struct reg *regs));
void setregs __P((struct proc *, u_long, u_long));
void setregs __P((struct proc *, u_long, u_long, u_long));
#endif
#endif /* !_MACHINE_REG_H_ */

View File

@ -35,7 +35,7 @@
* SUCH DAMAGE.
*
* from: @(#)machdep.c 7.4 (Berkeley) 6/3/91
* $Id: machdep.c,v 1.326 1999/02/13 17:45:15 bde Exp $
* $Id: machdep.c,v 1.327 1999/03/06 04:46:18 wollman Exp $
*/
#include "apm.h"
@ -806,10 +806,11 @@ cpu_halt(void)
* Clear registers on exec
*/
void
setregs(p, entry, stack)
setregs(p, entry, stack, ps_strings)
struct proc *p;
u_long entry;
u_long stack;
u_long ps_strings;
{
struct trapframe *regs = p->p_md.md_regs;
struct pcb *pcb = &p->p_addr->u_pcb;
@ -836,6 +837,9 @@ setregs(p, entry, stack)
regs->tf_es = _udatasel;
regs->tf_cs = _ucodesel;
/* PS_STRINGS value for BSD/OS binaries. It is 0 for non-BSD/OS. */
regs->tf_ebx = ps_strings;
/* reset %fs and %gs as well */
pcb->pcb_fs = _udatasel;
pcb->pcb_gs = _udatasel;

View File

@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* from: @(#)reg.h 5.5 (Berkeley) 1/18/91
* $Id: reg.h,v 1.15 1997/06/07 04:36:06 bde Exp $
* $Id: reg.h,v 1.16 1998/09/14 22:43:40 jdp Exp $
*/
#ifndef _MACHINE_REG_H_
@ -124,7 +124,7 @@ struct fpreg {
*/
int set_fpregs __P((struct proc *, struct fpreg *));
int set_regs __P((struct proc *p, struct reg *regs));
void setregs __P((struct proc *, u_long, u_long));
void setregs __P((struct proc *, u_long, u_long, u_long));
#endif
#endif /* !_MACHINE_REG_H_ */

View File

@ -95,7 +95,7 @@ svr4_setregs(p, epp, stack)
register struct pcb *pcb = &p->p_addr->u_pcb;
pcb->pcb_savefpu.sv_env.en_cw = __SVR4_NPXCW__;
setregs(p, epp, stack);
setregs(p, epp, stack, 0UL);
}
#endif /* __NetBSD__ */

View File

@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: imgact_aout.c,v 1.47 1999/03/04 18:04:40 alc Exp $
* $Id: imgact_aout.c,v 1.48 1999/03/10 07:07:42 alc Exp $
*/
#include <sys/param.h>
@ -119,6 +119,9 @@ exec_aout_imgact(imgp)
case QMAGIC:
virtual_offset = PAGE_SIZE;
file_offset = 0;
/* Pass PS_STRINGS for BSD/OS binaries only. */
if (N_GETMID(*a_out) == MID_ZERO)
imgp->ps_strings = PS_STRINGS;
break;
default:
/* NetBSD compatibility */

View File

@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: kern_exec.c,v 1.95 1999/01/28 00:57:47 dillon Exp $
* $Id: kern_exec.c,v 1.96 1999/02/19 14:25:34 luoqi Exp $
*/
#include <sys/param.h>
@ -117,6 +117,7 @@ execve(p, uap)
imgp->auxargs = NULL;
imgp->vp = NULL;
imgp->firstpage = NULL;
imgp->ps_strings = 0;
/*
* Allocate temporary demand zeroed space for argument and
@ -309,8 +310,9 @@ execve(p, uap)
/* clear "fork but no exec" flag, as we _are_ execing */
p->p_acflag &= ~AFORK;
/* Set entry address */
setregs(p, imgp->entry_addr, (u_long)(uintptr_t)stack_base);
/* Set values passed into the program in registers. */
setregs(p, imgp->entry_addr, (u_long)(uintptr_t)stack_base,
imgp->ps_strings);
exec_fail_dealloc:

View File

@ -35,7 +35,7 @@
* SUCH DAMAGE.
*
* from: @(#)machdep.c 7.4 (Berkeley) 6/3/91
* $Id: machdep.c,v 1.109 1999/02/16 11:07:06 kato Exp $
* $Id: machdep.c,v 1.110 1999/03/06 09:43:01 kato Exp $
*/
#include "apm.h"
@ -819,10 +819,11 @@ cpu_halt(void)
* Clear registers on exec
*/
void
setregs(p, entry, stack)
setregs(p, entry, stack, ps_strings)
struct proc *p;
u_long entry;
u_long stack;
u_long ps_strings;
{
struct trapframe *regs = p->p_md.md_regs;
struct pcb *pcb = &p->p_addr->u_pcb;

View File

@ -35,7 +35,7 @@
* SUCH DAMAGE.
*
* from: @(#)machdep.c 7.4 (Berkeley) 6/3/91
* $Id: machdep.c,v 1.109 1999/02/16 11:07:06 kato Exp $
* $Id: machdep.c,v 1.110 1999/03/06 09:43:01 kato Exp $
*/
#include "apm.h"
@ -819,10 +819,11 @@ cpu_halt(void)
* Clear registers on exec
*/
void
setregs(p, entry, stack)
setregs(p, entry, stack, ps_strings)
struct proc *p;
u_long entry;
u_long stack;
u_long ps_strings;
{
struct trapframe *regs = p->p_md.md_regs;
struct pcb *pcb = &p->p_addr->u_pcb;

View File

@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: imgact.h,v 1.17 1998/03/02 05:47:43 peter Exp $
* $Id: imgact.h,v 1.18 1998/12/30 10:38:59 dfr Exp $
*/
#ifndef _SYS_IMGACT_H_
@ -54,6 +54,7 @@ struct image_params {
void *auxargs; /* ELF Auxinfo structure pointer */
struct vm_page *firstpage; /* first page that we mapped */
char *fname; /* pointer to filename of executable (user space) */
unsigned long ps_strings; /* PS_STRINGS for BSD/OS binaries */
};
#ifdef KERNEL