From: Arun Thomas Date: Thu, 10 Jun 2010 14:59:10 +0000 (+0000) Subject: Make exec() use entry point in a.out header X-Git-Tag: v3.1.8~457 X-Git-Url: http://zhaoyanbai.com/repos/man.dnssec-revoke.html?a=commitdiff_plain;h=1bf6d23f347ae61a3a7e344e6b55b1a0dee961cd;p=minix.git Make exec() use entry point in a.out header --- diff --git a/include/minix/com.h b/include/minix/com.h index c0790cb99..9a2c2d4fc 100644 --- a/include/minix/com.h +++ b/include/minix/com.h @@ -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 * diff --git a/servers/pm/exec.c b/servers/pm/exec.c index 8da62e2d8..58301763c 100644 --- a/servers/pm/exec.c +++ b/servers/pm/exec.c @@ -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); } diff --git a/servers/pm/main.c b/servers/pm/main.c index 1c3c22d83..20d65f7b5 100644 --- a/servers/pm/main.c +++ b/servers/pm/main.c @@ -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; diff --git a/servers/pm/proto.h b/servers/pm/proto.h index e706806e7..48ce66389 100644 --- a/servers/pm/proto.h +++ b/servers/pm/proto.h @@ -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) ); diff --git a/servers/rs/exec.c b/servers/rs/exec.c index 0a9a4dfaf..3a43f69de 100644 --- a/servers/rs/exec.c +++ b/servers/rs/exec.c @@ -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; diff --git a/servers/vfs/exec.c b/servers/vfs/exec.c index 1551d3db5..ef0835726 100644 --- a/servers/vfs/exec.c +++ b/servers/vfs/exec.c @@ -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; diff --git a/servers/vfs/main.c b/servers/vfs/main.c index f2323fea4..d4be05cb2 100644 --- a/servers/vfs/main.c +++ b/servers/vfs/main.c @@ -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; diff --git a/servers/vfs/proto.h b/servers/vfs/proto.h index 27487a55c..8fad59a95 100644 --- a/servers/vfs/proto.h +++ b/servers/vfs/proto.h @@ -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) );