diff options
author | Richard Henderson <rth@twiddle.net> | 2010-07-27 10:25:30 -0700 |
---|---|---|
committer | Edgar E. Iglesias <edgar.iglesias@gmail.com> | 2010-07-29 08:32:28 +0200 |
commit | 9955ffac9a31aad346fe7f0fcefebe88da7f9df5 (patch) | |
tree | 6717fb9286c007302a39846fd6ecb4be088c0f18 /linux-user/linuxload.c | |
parent | d97ef72eed202460a13dfe4a92fd95ac9e6ddf11 (diff) | |
download | qemu-9955ffac9a31aad346fe7f0fcefebe88da7f9df5.zip qemu-9955ffac9a31aad346fe7f0fcefebe88da7f9df5.tar.gz qemu-9955ffac9a31aad346fe7f0fcefebe88da7f9df5.tar.bz2 |
linux-user: Reduce lseek+reads while loading elf files.
Define BPRM_BUF_SIZE to 1k and read that amount initially. If the
data we want from the binary is in this buffer, use it instead of
reading from the file again.
Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
Diffstat (limited to 'linux-user/linuxload.c')
-rw-r--r-- | linux-user/linuxload.c | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/linux-user/linuxload.c b/linux-user/linuxload.c index 13ad9aa..9ee27c3 100644 --- a/linux-user/linuxload.c +++ b/linux-user/linuxload.c @@ -96,18 +96,16 @@ static int prepare_binprm(struct linux_binprm *bprm) } } - retval = lseek(bprm->fd, 0L, SEEK_SET); - if(retval >= 0) { - retval = read(bprm->fd, bprm->buf, 128); - } - if(retval < 0) { + retval = read(bprm->fd, bprm->buf, BPRM_BUF_SIZE); + if (retval < 0) { perror("prepare_binprm"); exit(-1); - /* return(-errno); */ } - else { - return(retval); + if (retval < BPRM_BUF_SIZE) { + /* Make sure the rest of the loader won't read garbage. */ + memset(bprm->buf + retval, 0, BPRM_BUF_SIZE - retval); } + return retval; } /* Construct the envp and argv tables on the target stack. */ @@ -163,8 +161,7 @@ int loader_exec(const char * filename, char ** argv, char ** envp, 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; + memset(bprm->page, 0, sizeof(bprm->page)); retval = open(filename, O_RDONLY); if (retval < 0) return retval; |