summaryrefslogtreecommitdiff
path: root/linux-user/main.c
diff options
context:
space:
mode:
authorbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>2003-03-24 21:58:34 +0000
committerbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>2003-03-24 21:58:34 +0000
commitd691f66983c0b36689400e9e9137d72bd3be8e72 (patch)
treebf7422162d5f435af122b0a531a7eb03c6f60424 /linux-user/main.c
parent386405f78661e0a4f82087196c7b084b8c612b48 (diff)
downloadqemu-d691f66983c0b36689400e9e9137d72bd3be8e72.tar.gz
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/main.c')
-rw-r--r--linux-user/main.c46
1 files changed, 40 insertions, 6 deletions
diff --git a/linux-user/main.c b/linux-user/main.c
index 2899934266..31743253bb 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);
}