Make exec() use entry point in a.out header
This commit is contained in:
parent
f0a158d8c1
commit
1bf6d23f34
8 changed files with 25 additions and 15 deletions
|
@ -793,6 +793,7 @@
|
|||
|
||||
/* Additional parameters for PM_EXEC_REPLY and PM_CORE_REPLY */
|
||||
# define PM_STATUS m1_i2 /* OK or failure */
|
||||
# define PM_PC m1_p1 /* program counter */
|
||||
|
||||
/* Additional parameters for PM_FORK and PM_SRV_FORK */
|
||||
# define PM_PPROC m1_i2 /* parent process endpoint */
|
||||
|
@ -818,6 +819,7 @@
|
|||
/* Parameters for the EXEC_RESTART call */
|
||||
#define EXC_RS_PROC m1_i1 /* process that needs to be restarted */
|
||||
#define EXC_RS_RESULT m1_i2 /* result of the exec */
|
||||
#define EXC_RS_PC m1_p1 /* program counter */
|
||||
|
||||
/*===========================================================================*
|
||||
* Messages used from VFS to file servers *
|
||||
|
|
|
@ -118,6 +118,7 @@ PUBLIC int do_execrestart()
|
|||
{
|
||||
int proc_e, proc_n, result;
|
||||
struct mproc *rmp;
|
||||
vir_bytes pc;
|
||||
|
||||
if (who_e != RS_PROC_NR)
|
||||
return EPERM;
|
||||
|
@ -128,8 +129,9 @@ PUBLIC int do_execrestart()
|
|||
}
|
||||
rmp= &mproc[proc_n];
|
||||
result= m_in.EXC_RS_RESULT;
|
||||
pc= (vir_bytes)m_in.EXC_RS_PC;
|
||||
|
||||
exec_restart(rmp, result);
|
||||
exec_restart(rmp, result, pc);
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
@ -138,12 +140,12 @@ PUBLIC int do_execrestart()
|
|||
/*===========================================================================*
|
||||
* exec_restart *
|
||||
*===========================================================================*/
|
||||
PUBLIC void exec_restart(rmp, result)
|
||||
PUBLIC void exec_restart(rmp, result, pc)
|
||||
struct mproc *rmp;
|
||||
int result;
|
||||
vir_bytes pc;
|
||||
{
|
||||
int r, sn;
|
||||
vir_bytes pc;
|
||||
char *new_sp;
|
||||
|
||||
if (result != OK)
|
||||
|
@ -182,7 +184,6 @@ int result;
|
|||
}
|
||||
|
||||
new_sp= (char *)rmp->mp_procargs;
|
||||
pc= 0; /* for now */
|
||||
r= sys_exec(rmp->mp_endpoint, new_sp, rmp->mp_name, pc);
|
||||
if (r != OK) panic("sys_exec failed: %d", r);
|
||||
}
|
||||
|
|
|
@ -472,7 +472,7 @@ PRIVATE void handle_vfs_reply()
|
|||
break;
|
||||
|
||||
case PM_EXEC_REPLY:
|
||||
exec_restart(rmp, m_in.PM_STATUS);
|
||||
exec_restart(rmp, m_in.PM_STATUS, (vir_bytes)m_in.PM_PC);
|
||||
|
||||
break;
|
||||
|
||||
|
|
|
@ -25,7 +25,8 @@ _PROTOTYPE( int do_getdma, (void) );
|
|||
_PROTOTYPE( int do_exec, (void) );
|
||||
_PROTOTYPE( int do_exec_newmem, (void) );
|
||||
_PROTOTYPE( int do_execrestart, (void) );
|
||||
_PROTOTYPE( void exec_restart, (struct mproc *rmp, int result) );
|
||||
_PROTOTYPE( void exec_restart, (struct mproc *rmp, int result,
|
||||
vir_bytes pc) );
|
||||
|
||||
/* forkexit.c */
|
||||
_PROTOTYPE( int do_fork, (void) );
|
||||
|
|
|
@ -15,7 +15,8 @@ FORWARD _PROTOTYPE( int exec_newmem, (int proc_e, vir_bytes text_bytes,
|
|||
dev_t st_dev, ino_t st_ino, time_t st_ctime, char *progname,
|
||||
int new_uid, int new_gid,
|
||||
vir_bytes *stack_topp, int *load_textp, int *allow_setuidp) );
|
||||
FORWARD _PROTOTYPE( int exec_restart, (int proc_e, int result) );
|
||||
FORWARD _PROTOTYPE( int exec_restart, (int proc_e, int result,
|
||||
vir_bytes pc) );
|
||||
FORWARD _PROTOTYPE( void patch_ptr, (char stack[ARG_MAX],
|
||||
vir_bytes base) );
|
||||
FORWARD _PROTOTYPE( int read_seg, (char *exec, size_t exec_len, off_t off,
|
||||
|
@ -191,12 +192,12 @@ static int do_exec(int proc_e, char *exec, size_t exec_len, char *progname,
|
|||
goto fail;
|
||||
}
|
||||
|
||||
return exec_restart(proc_e, OK);
|
||||
return exec_restart(proc_e, OK, pc);
|
||||
|
||||
fail:
|
||||
printf("do_exec(fail): error = %d\n", error);
|
||||
if (need_restart)
|
||||
exec_restart(proc_e, error);
|
||||
exec_restart(proc_e, error, pc);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
@ -264,9 +265,10 @@ PRIVATE int exec_newmem(
|
|||
/*===========================================================================*
|
||||
* exec_restart *
|
||||
*===========================================================================*/
|
||||
PRIVATE int exec_restart(proc_e, result)
|
||||
PRIVATE int exec_restart(proc_e, result, pc)
|
||||
int proc_e;
|
||||
int result;
|
||||
vir_bytes pc;
|
||||
{
|
||||
int r;
|
||||
message m;
|
||||
|
@ -274,6 +276,7 @@ int result;
|
|||
m.m_type= EXEC_RESTART;
|
||||
m.EXC_RS_PROC= proc_e;
|
||||
m.EXC_RS_RESULT= result;
|
||||
m.EXC_RS_PC= (void*)pc;
|
||||
r= sendrec(PM_PROC_NR, &m);
|
||||
if (r != OK)
|
||||
return r;
|
||||
|
|
|
@ -56,19 +56,20 @@ FORWARD _PROTOTYPE( void clo_exec, (struct fproc *rfp) );
|
|||
/*===========================================================================*
|
||||
* pm_exec *
|
||||
*===========================================================================*/
|
||||
PUBLIC int pm_exec(proc_e, path, path_len, frame, frame_len)
|
||||
PUBLIC int pm_exec(proc_e, path, path_len, frame, frame_len, pc)
|
||||
int proc_e;
|
||||
char *path;
|
||||
vir_bytes path_len;
|
||||
char *frame;
|
||||
vir_bytes frame_len;
|
||||
vir_bytes *pc;
|
||||
{
|
||||
/* Perform the execve(name, argv, envp) call. The user library builds a
|
||||
* complete stack image, including pointers, args, environ, etc. The stack
|
||||
* is copied to a buffer inside VFS, and then to the new core image.
|
||||
*/
|
||||
int r, r1, sep_id, round, proc_s, hdrlen, load_text, allow_setuid;
|
||||
vir_bytes text_bytes, data_bytes, bss_bytes, pc;
|
||||
vir_bytes text_bytes, data_bytes, bss_bytes;
|
||||
phys_bytes tot_bytes; /* total space for program, including gap */
|
||||
vir_bytes stack_top, vsp;
|
||||
off_t off;
|
||||
|
@ -137,7 +138,7 @@ vir_bytes frame_len;
|
|||
|
||||
/* Read the file header and extract the segment sizes. */
|
||||
r = read_header(vp, &sep_id, &text_bytes, &data_bytes, &bss_bytes,
|
||||
&tot_bytes, &pc, &hdrlen);
|
||||
&tot_bytes, pc, &hdrlen);
|
||||
if (r != ESCRIPT || round != 0)
|
||||
break;
|
||||
|
||||
|
|
|
@ -525,6 +525,7 @@ PRIVATE void init_root()
|
|||
PRIVATE void service_pm()
|
||||
{
|
||||
int r;
|
||||
vir_bytes pc;
|
||||
|
||||
switch (call_nr) {
|
||||
case PM_SETUID:
|
||||
|
@ -553,11 +554,12 @@ PRIVATE void service_pm()
|
|||
|
||||
case PM_EXEC:
|
||||
r = pm_exec(m_in.PM_PROC, m_in.PM_PATH, m_in.PM_PATH_LEN,
|
||||
m_in.PM_FRAME, m_in.PM_FRAME_LEN);
|
||||
m_in.PM_FRAME, m_in.PM_FRAME_LEN, &pc);
|
||||
|
||||
/* Reply status to PM */
|
||||
m_out.m_type = PM_EXEC_REPLY;
|
||||
m_out.PM_PROC = m_in.PM_PROC;
|
||||
m_out.PM_PC = (void*)pc;
|
||||
m_out.PM_STATUS = r;
|
||||
|
||||
break;
|
||||
|
|
|
@ -45,7 +45,7 @@ _PROTOTYPE( void dmap_endpt_up, (int proc_nr) );
|
|||
|
||||
/* exec.c */
|
||||
_PROTOTYPE( int pm_exec, (int proc_e, char *path, vir_bytes path_len,
|
||||
char *frame, vir_bytes frame_len) );
|
||||
char *frame, vir_bytes frame_len, vir_bytes *pc));
|
||||
|
||||
/* filedes.c */
|
||||
_PROTOTYPE( struct filp *find_filp, (struct vnode *vp, mode_t bits) );
|
||||
|
|
Loading…
Reference in a new issue