ld.so load fix

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@47 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
bellard 2003-03-24 23:00:36 +00:00
parent d691f66983
commit 644c433cb3
3 changed files with 19 additions and 8 deletions

8
README
View File

@ -23,8 +23,12 @@ libraries installed on your PC. For example:
./qemu -L / /bin/ls ./qemu -L / /bin/ls
* On non x86 CPUs, you need first to download at least an x86 glibc * On non x86 CPUs, you need first to download at least an x86 glibc
(qemu-i386-glibc21.tar.gz on the qemu web page). Then you can launch (qemu-i386-glibc21.tar.gz on the qemu web page). Ensure that
the precompiled 'ls' x86 executable: LD_LIBRARY_PATH is not set:
unset LD_LIBRARY_PATH
Then you can launch the precompiled 'ls' x86 executable:
./qemu /usr/local/qemu-i386/bin/ls ./qemu /usr/local/qemu-i386/bin/ls

View File

@ -360,9 +360,6 @@ static unsigned int * create_elf_tables(char *p, int argc, int envc,
put_user (tswapl(val), dlinfo++) put_user (tswapl(val), dlinfo++)
if (exec) { /* Put this here for an ELF program interpreter */ if (exec) { /* Put this here for an ELF program interpreter */
struct elf_phdr * eppnt;
eppnt = (struct elf_phdr *)((unsigned long)exec->e_phoff);
NEW_AUX_ENT (AT_PHDR, (unsigned int)(load_addr + exec->e_phoff)); NEW_AUX_ENT (AT_PHDR, (unsigned int)(load_addr + exec->e_phoff));
NEW_AUX_ENT (AT_PHENT, (unsigned int)(sizeof (struct elf_phdr))); NEW_AUX_ENT (AT_PHENT, (unsigned int)(sizeof (struct elf_phdr)));
NEW_AUX_ENT (AT_PHNUM, (unsigned int)(exec->e_phnum)); NEW_AUX_ENT (AT_PHNUM, (unsigned int)(exec->e_phnum));
@ -418,6 +415,9 @@ static unsigned long load_elf_interp(struct elfhdr * interp_elf_ex,
*/ */
load_addr = INTERP_LOADADDR; load_addr = INTERP_LOADADDR;
#ifdef BSWAP_NEEDED
bswap_ehdr(interp_elf_ex);
#endif
/* First of all, some simple consistency checks */ /* First of all, some simple consistency checks */
if ((interp_elf_ex->e_type != ET_EXEC && if ((interp_elf_ex->e_type != ET_EXEC &&
interp_elf_ex->e_type != ET_DYN) || interp_elf_ex->e_type != ET_DYN) ||
@ -425,6 +425,7 @@ static unsigned long load_elf_interp(struct elfhdr * interp_elf_ex,
return ~0UL; return ~0UL;
} }
/* Now read in all of the header information */ /* Now read in all of the header information */
if (sizeof(struct elf_phdr) * interp_elf_ex->e_phnum > X86_PAGE_SIZE) if (sizeof(struct elf_phdr) * interp_elf_ex->e_phnum > X86_PAGE_SIZE)
@ -452,7 +453,6 @@ static unsigned long load_elf_interp(struct elfhdr * interp_elf_ex,
(char *) elf_phdata, (char *) elf_phdata,
sizeof(struct elf_phdr) * interp_elf_ex->e_phnum); sizeof(struct elf_phdr) * interp_elf_ex->e_phnum);
} }
if (retval < 0) { if (retval < 0) {
perror("load_elf_interp"); perror("load_elf_interp");
exit(-1); exit(-1);

View File

@ -92,8 +92,15 @@ qemu -L / /bin/ls
@item On non x86 CPUs, you need first to download at least an x86 glibc @item On non x86 CPUs, you need first to download at least an x86 glibc
(@file{qemu-i386-glibc21.tar.gz} on the QEMU web page). Then you can (@file{qemu-i386-glibc21.tar.gz} on the QEMU web page). Ensure that
launch the precompiled @file{ls} x86 executable: @code{LD_LIBRARY_PATH} is not set:
@example
unset LD_LIBRARY_PATH
@end example
Then you can launch the precompiled @file{ls} x86 executable:
@example @example
qemu /usr/local/qemu-i386/bin/ls qemu /usr/local/qemu-i386/bin/ls
@end example @end example