Revision d691f669 linux-user/main.c
b/linux-user/main.c | ||
---|---|---|
32 | 32 |
|
33 | 33 |
FILE *logfile = NULL; |
34 | 34 |
int loglevel; |
35 |
const char *interp_prefix = CONFIG_QEMU_PREFIX "/qemu-i386"; |
|
35 | 36 |
|
36 | 37 |
/* XXX: on x86 MAP_GROWSDOWN only works if ESP <= address + 32, so |
37 | 38 |
we allocate a bigger stack. Need a better solution, for example |
... | ... | |
172 | 173 |
void usage(void) |
173 | 174 |
{ |
174 | 175 |
printf("qemu version " QEMU_VERSION ", Copyright (c) 2003 Fabrice Bellard\n" |
175 |
"usage: qemu [-d] program [arguments...]\n"
|
|
176 |
"usage: qemu [-h] [-d] [-L path] [-s size] program [arguments...]\n"
|
|
176 | 177 |
"Linux x86 emulator\n" |
177 |
); |
|
178 |
"\n" |
|
179 |
"-h print this help\n" |
|
180 |
"-d activate log (logfile=%s)\n" |
|
181 |
"-L path set the x86 elf interpreter prefix (default=%s)\n" |
|
182 |
"-s size set the x86 stack size in bytes (default=%ld)\n", |
|
183 |
DEBUG_LOGFILE, |
|
184 |
interp_prefix, |
|
185 |
x86_stack_size); |
|
178 | 186 |
exit(1); |
179 | 187 |
} |
180 | 188 |
|
... | ... | |
188 | 196 |
struct image_info info1, *info = &info1; |
189 | 197 |
CPUX86State *env; |
190 | 198 |
int optind; |
191 |
|
|
199 |
const char *r; |
|
200 |
|
|
192 | 201 |
if (argc <= 1) |
193 | 202 |
usage(); |
194 | 203 |
loglevel = 0; |
195 | 204 |
optind = 1; |
196 |
if (argv[optind] && !strcmp(argv[optind], "-d")) { |
|
197 |
loglevel = 1; |
|
205 |
for(;;) { |
|
206 |
if (optind >= argc) |
|
207 |
break; |
|
208 |
r = argv[optind]; |
|
209 |
if (r[0] != '-') |
|
210 |
break; |
|
198 | 211 |
optind++; |
212 |
r++; |
|
213 |
if (!strcmp(r, "-")) { |
|
214 |
break; |
|
215 |
} else if (!strcmp(r, "d")) { |
|
216 |
loglevel = 1; |
|
217 |
} else if (!strcmp(r, "s")) { |
|
218 |
r = argv[optind++]; |
|
219 |
x86_stack_size = strtol(r, (char **)&r, 0); |
|
220 |
if (x86_stack_size <= 0) |
|
221 |
usage(); |
|
222 |
if (*r == 'M') |
|
223 |
x86_stack_size *= 1024 * 1024; |
|
224 |
else if (*r == 'k' || *r == 'K') |
|
225 |
x86_stack_size *= 1024; |
|
226 |
} else if (!strcmp(r, "L")) { |
|
227 |
interp_prefix = argv[optind++]; |
|
228 |
} else { |
|
229 |
usage(); |
|
230 |
} |
|
199 | 231 |
} |
232 |
if (optind >= argc) |
|
233 |
usage(); |
|
200 | 234 |
filename = argv[optind]; |
201 | 235 |
|
202 | 236 |
/* init debug */ |
... | ... | |
215 | 249 |
/* Zero out image_info */ |
216 | 250 |
memset(info, 0, sizeof(struct image_info)); |
217 | 251 |
|
218 |
if(elf_exec(filename, argv+optind, environ, regs, info) != 0) { |
|
252 |
if(elf_exec(interp_prefix, filename, argv+optind, environ, regs, info) != 0) {
|
|
219 | 253 |
printf("Error loading %s\n", filename); |
220 | 254 |
exit(1); |
221 | 255 |
} |
Also available in: Unified diff