diff options
author | bellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162> | 2003-03-24 21:58:34 +0000 |
---|---|---|
committer | bellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162> | 2003-03-24 21:58:34 +0000 |
commit | d691f66983c0b36689400e9e9137d72bd3be8e72 (patch) | |
tree | bf7422162d5f435af122b0a531a7eb03c6f60424 /linux-user | |
parent | 386405f78661e0a4f82087196c7b084b8c612b48 (diff) | |
download | qemu-d691f66983c0b36689400e9e9137d72bd3be8e72.zip qemu-d691f66983c0b36689400e9e9137d72bd3be8e72.tar.gz qemu-d691f66983c0b36689400e9e9137d72bd3be8e72.tar.bz2 |
glibc2.2 fixes - more command line options - misc doc fixesv0.1.1
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@46 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'linux-user')
-rw-r--r-- | linux-user/elfload.c | 14 | ||||
-rw-r--r-- | linux-user/main.c | 46 | ||||
-rw-r--r-- | linux-user/qemu.h | 3 |
3 files changed, 50 insertions, 13 deletions
diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 44ac577..817913d 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -42,8 +42,7 @@ #define DLINFO_ITEMS 12 /* Where we find X86 libraries... */ -//#define X86_DEFAULT_LIB_DIR "/usr/x86/" -#define X86_DEFAULT_LIB_DIR "/" + //extern void * mmap4k(); #define mmap4k(a, b, c, d, e, f) mmap((void *)(a), b, c, d, e, f) @@ -638,7 +637,8 @@ static int load_elf_binary(struct linux_binprm * bprm, struct target_pt_regs * r * is an a.out format binary */ - elf_interpreter = (char *)malloc(elf_ppnt->p_filesz+strlen(X86_DEFAULT_LIB_DIR)); + elf_interpreter = (char *)malloc(elf_ppnt->p_filesz+ + strlen(bprm->interp_prefix)); if (elf_interpreter == NULL) { free (elf_phdata); @@ -646,11 +646,11 @@ static int load_elf_binary(struct linux_binprm * bprm, struct target_pt_regs * r return -ENOMEM; } - strcpy(elf_interpreter, X86_DEFAULT_LIB_DIR); + strcpy(elf_interpreter, bprm->interp_prefix); retval = lseek(bprm->fd, elf_ppnt->p_offset, SEEK_SET); if(retval >= 0) { retval = read(bprm->fd, - elf_interpreter+strlen(X86_DEFAULT_LIB_DIR), + elf_interpreter+strlen(bprm->interp_prefix), elf_ppnt->p_filesz); } if(retval < 0) { @@ -911,7 +911,8 @@ static int load_elf_binary(struct linux_binprm * bprm, struct target_pt_regs * r -int elf_exec(const char * filename, char ** argv, char ** envp, +int elf_exec(const char *interp_prefix, + const char * filename, char ** argv, char ** envp, struct target_pt_regs * regs, struct image_info *infop) { struct linux_binprm bprm; @@ -930,6 +931,7 @@ int elf_exec(const char * filename, char ** argv, char ** envp, else { bprm.fd = retval; } + bprm.interp_prefix = (char *)interp_prefix; bprm.filename = (char *)filename; bprm.sh_bang = 0; bprm.loader = 0; diff --git a/linux-user/main.c b/linux-user/main.c index 2899934..3174325 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -32,6 +32,7 @@ FILE *logfile = NULL; int loglevel; +const char *interp_prefix = CONFIG_QEMU_PREFIX "/qemu-i386"; /* XXX: on x86 MAP_GROWSDOWN only works if ESP <= address + 32, so we allocate a bigger stack. Need a better solution, for example @@ -172,9 +173,16 @@ void cpu_loop(struct CPUX86State *env) void usage(void) { printf("qemu version " QEMU_VERSION ", Copyright (c) 2003 Fabrice Bellard\n" - "usage: qemu [-d] program [arguments...]\n" + "usage: qemu [-h] [-d] [-L path] [-s size] program [arguments...]\n" "Linux x86 emulator\n" - ); + "\n" + "-h print this help\n" + "-d activate log (logfile=%s)\n" + "-L path set the x86 elf interpreter prefix (default=%s)\n" + "-s size set the x86 stack size in bytes (default=%ld)\n", + DEBUG_LOGFILE, + interp_prefix, + x86_stack_size); exit(1); } @@ -188,15 +196,41 @@ int main(int argc, char **argv) struct image_info info1, *info = &info1; CPUX86State *env; int optind; - + const char *r; + if (argc <= 1) usage(); loglevel = 0; optind = 1; - if (argv[optind] && !strcmp(argv[optind], "-d")) { - loglevel = 1; + for(;;) { + if (optind >= argc) + break; + r = argv[optind]; + if (r[0] != '-') + break; optind++; + r++; + if (!strcmp(r, "-")) { + break; + } else if (!strcmp(r, "d")) { + loglevel = 1; + } else if (!strcmp(r, "s")) { + r = argv[optind++]; + x86_stack_size = strtol(r, (char **)&r, 0); + if (x86_stack_size <= 0) + usage(); + if (*r == 'M') + x86_stack_size *= 1024 * 1024; + else if (*r == 'k' || *r == 'K') + x86_stack_size *= 1024; + } else if (!strcmp(r, "L")) { + interp_prefix = argv[optind++]; + } else { + usage(); + } } + if (optind >= argc) + usage(); filename = argv[optind]; /* init debug */ @@ -215,7 +249,7 @@ int main(int argc, char **argv) /* Zero out image_info */ memset(info, 0, sizeof(struct image_info)); - if(elf_exec(filename, argv+optind, environ, regs, info) != 0) { + if(elf_exec(interp_prefix, filename, argv+optind, environ, regs, info) != 0) { printf("Error loading %s\n", filename); exit(1); } diff --git a/linux-user/qemu.h b/linux-user/qemu.h index 8626955..d4d93a4 100644 --- a/linux-user/qemu.h +++ b/linux-user/qemu.h @@ -33,7 +33,8 @@ struct image_info { int personality; }; -int elf_exec(const char * filename, char ** argv, char ** envp, +int elf_exec(const char *interp_prefix, + const char * filename, char ** argv, char ** envp, struct target_pt_regs * regs, struct image_info *infop); void target_set_brk(char *new_brk); |