glibc2.2 fixes - more command line options - misc doc fixes

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@46 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
bellard 2003-03-24 21:58:34 +00:00
parent 386405f786
commit d691f66983
14 changed files with 178 additions and 51 deletions

View file

@ -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;

View file

@ -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);
}

View file

@ -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);