Commit 644c433cb3759599aa1440b412964f8e49cc0b71

Authored by bellard
1 parent d691f669

ld.so load fix


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@47 c046a42c-6fe2-441c-8c8c-71466251a162
@@ -23,8 +23,12 @@ libraries installed on your PC. For example: @@ -23,8 +23,12 @@ libraries installed on your PC. For example:
23 ./qemu -L / /bin/ls 23 ./qemu -L / /bin/ls
24 24
25 * On non x86 CPUs, you need first to download at least an x86 glibc 25 * On non x86 CPUs, you need first to download at least an x86 glibc
26 -(qemu-i386-glibc21.tar.gz on the qemu web page). Then you can launch  
27 -the precompiled 'ls' x86 executable: 26 +(qemu-i386-glibc21.tar.gz on the qemu web page). Ensure that
  27 +LD_LIBRARY_PATH is not set:
  28 +
  29 + unset LD_LIBRARY_PATH
  30 +
  31 +Then you can launch the precompiled 'ls' x86 executable:
28 32
29 ./qemu /usr/local/qemu-i386/bin/ls 33 ./qemu /usr/local/qemu-i386/bin/ls
30 34
linux-user/elfload.c
@@ -360,9 +360,6 @@ static unsigned int * create_elf_tables(char *p, int argc, int envc, @@ -360,9 +360,6 @@ static unsigned int * create_elf_tables(char *p, int argc, int envc,
360 put_user (tswapl(val), dlinfo++) 360 put_user (tswapl(val), dlinfo++)
361 361
362 if (exec) { /* Put this here for an ELF program interpreter */ 362 if (exec) { /* Put this here for an ELF program interpreter */
363 - struct elf_phdr * eppnt;  
364 - eppnt = (struct elf_phdr *)((unsigned long)exec->e_phoff);  
365 -  
366 NEW_AUX_ENT (AT_PHDR, (unsigned int)(load_addr + exec->e_phoff)); 363 NEW_AUX_ENT (AT_PHDR, (unsigned int)(load_addr + exec->e_phoff));
367 NEW_AUX_ENT (AT_PHENT, (unsigned int)(sizeof (struct elf_phdr))); 364 NEW_AUX_ENT (AT_PHENT, (unsigned int)(sizeof (struct elf_phdr)));
368 NEW_AUX_ENT (AT_PHNUM, (unsigned int)(exec->e_phnum)); 365 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, @@ -418,6 +415,9 @@ static unsigned long load_elf_interp(struct elfhdr * interp_elf_ex,
418 */ 415 */
419 load_addr = INTERP_LOADADDR; 416 load_addr = INTERP_LOADADDR;
420 417
  418 +#ifdef BSWAP_NEEDED
  419 + bswap_ehdr(interp_elf_ex);
  420 +#endif
421 /* First of all, some simple consistency checks */ 421 /* First of all, some simple consistency checks */
422 if ((interp_elf_ex->e_type != ET_EXEC && 422 if ((interp_elf_ex->e_type != ET_EXEC &&
423 interp_elf_ex->e_type != ET_DYN) || 423 interp_elf_ex->e_type != ET_DYN) ||
@@ -425,6 +425,7 @@ static unsigned long load_elf_interp(struct elfhdr * interp_elf_ex, @@ -425,6 +425,7 @@ static unsigned long load_elf_interp(struct elfhdr * interp_elf_ex,
425 return ~0UL; 425 return ~0UL;
426 } 426 }
427 427
  428 +
428 /* Now read in all of the header information */ 429 /* Now read in all of the header information */
429 430
430 if (sizeof(struct elf_phdr) * interp_elf_ex->e_phnum > X86_PAGE_SIZE) 431 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, @@ -452,7 +453,6 @@ static unsigned long load_elf_interp(struct elfhdr * interp_elf_ex,
452 (char *) elf_phdata, 453 (char *) elf_phdata,
453 sizeof(struct elf_phdr) * interp_elf_ex->e_phnum); 454 sizeof(struct elf_phdr) * interp_elf_ex->e_phnum);
454 } 455 }
455 -  
456 if (retval < 0) { 456 if (retval < 0) {
457 perror("load_elf_interp"); 457 perror("load_elf_interp");
458 exit(-1); 458 exit(-1);
qemu-doc.texi
@@ -92,8 +92,15 @@ qemu -L / /bin/ls @@ -92,8 +92,15 @@ qemu -L / /bin/ls
92 92
93 93
94 @item On non x86 CPUs, you need first to download at least an x86 glibc 94 @item On non x86 CPUs, you need first to download at least an x86 glibc
95 -(@file{qemu-i386-glibc21.tar.gz} on the QEMU web page). Then you can  
96 -launch the precompiled @file{ls} x86 executable: 95 +(@file{qemu-i386-glibc21.tar.gz} on the QEMU web page). Ensure that
  96 +@code{LD_LIBRARY_PATH} is not set:
  97 +
  98 +@example
  99 +unset LD_LIBRARY_PATH
  100 +@end example
  101 +
  102 +Then you can launch the precompiled @file{ls} x86 executable:
  103 +
97 @example 104 @example
98 qemu /usr/local/qemu-i386/bin/ls 105 qemu /usr/local/qemu-i386/bin/ls
99 @end example 106 @end example