mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-26 20:03:54 -06:00
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>
This commit is contained in:
parent
d97ef72eed
commit
9955ffac9a
3 changed files with 57 additions and 71 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue