Commit f801f97e049b3cd832f50b9743184d0e87155193

Authored by bellard
1 parent f48c3dd5

personality fix - i386 interpreter fix


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@73 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 16 additions and 0 deletions
linux-user/main.c
... ... @@ -23,6 +23,9 @@
23 23 #include <string.h>
24 24 #include <errno.h>
25 25 #include <unistd.h>
  26 +#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)
  27 +#include <sys/personality.h>
  28 +#endif
26 29  
27 30 #include "qemu.h"
28 31  
... ... @@ -34,6 +37,12 @@ FILE *logfile = NULL;
34 37 int loglevel;
35 38 const char *interp_prefix = CONFIG_QEMU_PREFIX "/qemu-i386";
36 39  
  40 +#ifdef __i386__
  41 +/* Force usage of an ELF interpreter even if it is an ELF shared
  42 + object ! */
  43 +const char interp[] __attribute__((section(".interp"))) = "/lib/ld-linux.so.2";
  44 +#endif
  45 +
37 46 /* XXX: on x86 MAP_GROWSDOWN only works if ESP <= address + 32, so
38 47 we allocate a bigger stack. Need a better solution, for example
39 48 by remapping the process stack directly at the right place */
... ... @@ -370,6 +379,13 @@ int main(int argc, char **argv)
370 379  
371 380 if (argc <= 1)
372 381 usage();
  382 +
  383 + /* Set personality to X86_LINUX. May fail on unpatched kernels:
  384 + if so, they need to have munged paths themselves (eg. chroot,
  385 + hacked ld.so, whatever). */
  386 + if (personality(0x11) >= 0)
  387 + interp_prefix = "";
  388 +
373 389 loglevel = 0;
374 390 optind = 1;
375 391 for(;;) {
... ...