mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-26 20:03:54 -06:00
bsd-user: pass the bsd_param into loader_exec
Pass the bsd_param into loader_exec, and adjust. We use it to track the inital stack allocation and to set stack, open files, and other state shared between bsdload.c and elfload.c Signed-off-by: Warner Losh <imp@bsdimp.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
This commit is contained in:
parent
66ef252fab
commit
d37853f92f
3 changed files with 27 additions and 20 deletions
|
@ -140,35 +140,36 @@ abi_ulong loader_build_argptr(int envc, int argc, abi_ulong sp,
|
|||
}
|
||||
|
||||
int loader_exec(const char *filename, char **argv, char **envp,
|
||||
struct target_pt_regs *regs, struct image_info *infop)
|
||||
struct target_pt_regs *regs, struct image_info *infop,
|
||||
struct bsd_binprm *bprm)
|
||||
{
|
||||
struct bsd_binprm bprm;
|
||||
int retval;
|
||||
int i;
|
||||
|
||||
bprm.p = TARGET_PAGE_SIZE * MAX_ARG_PAGES - sizeof(unsigned int);
|
||||
for (i = 0 ; i < MAX_ARG_PAGES ; i++) { /* clear page-table */
|
||||
bprm.page[i] = NULL;
|
||||
bprm->p = TARGET_PAGE_SIZE * MAX_ARG_PAGES - sizeof(unsigned int);
|
||||
for (i = 0; i < MAX_ARG_PAGES; i++) { /* clear page-table */
|
||||
bprm->page[i] = NULL;
|
||||
}
|
||||
retval = open(filename, O_RDONLY);
|
||||
if (retval < 0) {
|
||||
return retval;
|
||||
}
|
||||
bprm.fd = retval;
|
||||
bprm.filename = (char *)filename;
|
||||
bprm.argc = count(argv);
|
||||
bprm.argv = argv;
|
||||
bprm.envc = count(envp);
|
||||
bprm.envp = envp;
|
||||
|
||||
retval = prepare_binprm(&bprm);
|
||||
bprm->fd = retval;
|
||||
bprm->filename = (char *)filename;
|
||||
bprm->argc = count(argv);
|
||||
bprm->argv = argv;
|
||||
bprm->envc = count(envp);
|
||||
bprm->envp = envp;
|
||||
|
||||
retval = prepare_binprm(bprm);
|
||||
|
||||
if (retval >= 0) {
|
||||
if (bprm.buf[0] == 0x7f
|
||||
&& bprm.buf[1] == 'E'
|
||||
&& bprm.buf[2] == 'L'
|
||||
&& bprm.buf[3] == 'F') {
|
||||
retval = load_elf_binary(&bprm, regs, infop);
|
||||
if (bprm->buf[0] == 0x7f
|
||||
&& bprm->buf[1] == 'E'
|
||||
&& bprm->buf[2] == 'L'
|
||||
&& bprm->buf[3] == 'F') {
|
||||
retval = load_elf_binary(bprm, regs, infop);
|
||||
} else {
|
||||
fprintf(stderr, "Unknown binary format\n");
|
||||
return -1;
|
||||
|
@ -183,7 +184,7 @@ int loader_exec(const char *filename, char **argv, char **envp,
|
|||
|
||||
/* Something went wrong, return the inode and free the argument pages*/
|
||||
for (i = 0 ; i < MAX_ARG_PAGES ; i++) {
|
||||
g_free(bprm.page[i]);
|
||||
g_free(bprm->page[i]);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue