From edf8e2af1453ce56c72b2f25a745e3734177a05d Mon Sep 17 00:00:00 2001 From: Mika Westerberg Date: Tue, 7 Apr 2009 09:57:11 +0300 Subject: linux-user: implemented ELF coredump support for ARM target When target process is killed with signal (such signal that should dump core) a coredump file is created. This file is similar than coredump generated by Linux (there are few exceptions though). Riku Voipio: added support for rlimit Signed-off-by: Mika Westerberg Signed-off-by: Riku Voipio --- linux-user/linuxload.c | 50 ++++++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 24 deletions(-) (limited to 'linux-user/linuxload.c') diff --git a/linux-user/linuxload.c b/linux-user/linuxload.c index ada7c697d2..14c433ea23 100644 --- a/linux-user/linuxload.c +++ b/linux-user/linuxload.c @@ -115,6 +115,7 @@ static int prepare_binprm(struct linux_binprm *bprm) abi_ulong loader_build_argptr(int envc, int argc, abi_ulong sp, abi_ulong stringp, int push_ptr) { + TaskState *ts = (TaskState *)thread_env->opaque; int n = sizeof(abi_ulong); abi_ulong envp; abi_ulong argv; @@ -133,13 +134,14 @@ abi_ulong loader_build_argptr(int envc, int argc, abi_ulong sp, sp -= n; /* FIXME - handle put_user() failures */ put_user_ual(argc, sp); - + ts->info->arg_start = stringp; while (argc-- > 0) { /* FIXME - handle put_user() failures */ put_user_ual(stringp, argv); argv += n; stringp += target_strlen(stringp) + 1; } + ts->info->arg_end = stringp; /* FIXME - handle put_user() failures */ put_user_ual(0, argv); while (envc-- > 0) { @@ -155,45 +157,45 @@ 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 linux_binprm *bprm) { - struct linux_binprm bprm; int retval; int i; - bprm.p = TARGET_PAGE_SIZE*MAX_ARG_PAGES-sizeof(unsigned int); + bprm->p = TARGET_PAGE_SIZE*MAX_ARG_PAGES-sizeof(unsigned int); for (i=0 ; ipage[i] = 0; 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; + 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); + retval = prepare_binprm(bprm); infop->host_argv = argv; if(retval>=0) { - if (bprm.buf[0] == 0x7f - && bprm.buf[1] == 'E' - && bprm.buf[2] == 'L' - && bprm.buf[3] == 'F') { + if (bprm->buf[0] == 0x7f + && bprm->buf[1] == 'E' + && bprm->buf[2] == 'L' + && bprm->buf[3] == 'F') { #ifndef TARGET_HAS_ELFLOAD32 - retval = load_elf_binary(&bprm,regs,infop); + retval = load_elf_binary(bprm,regs,infop); #else - retval = load_elf_binary_multi(&bprm, regs, infop); + retval = load_elf_binary_multi(bprm, regs, infop); #endif #if defined(TARGET_HAS_BFLT) - } else if (bprm.buf[0] == 'b' - && bprm.buf[1] == 'F' - && bprm.buf[2] == 'L' - && bprm.buf[3] == 'T') { - retval = load_flt_binary(&bprm,regs,infop); + } else if (bprm->buf[0] == 'b' + && bprm->buf[1] == 'F' + && bprm->buf[2] == 'L' + && bprm->buf[3] == 'T') { + retval = load_flt_binary(bprm,regs,infop); #endif } else { fprintf(stderr, "Unknown binary format\n"); @@ -209,7 +211,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 ; ipage[i]); } return(retval); } -- cgit v1.2.3-55-g7522