Commit f801f97e049b3cd832f50b9743184d0e87155193
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,6 +23,9 @@ | ||
| 23 | #include <string.h> | 23 | #include <string.h> |
| 24 | #include <errno.h> | 24 | #include <errno.h> |
| 25 | #include <unistd.h> | 25 | #include <unistd.h> |
| 26 | +#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3) | ||
| 27 | +#include <sys/personality.h> | ||
| 28 | +#endif | ||
| 26 | 29 | ||
| 27 | #include "qemu.h" | 30 | #include "qemu.h" |
| 28 | 31 | ||
| @@ -34,6 +37,12 @@ FILE *logfile = NULL; | @@ -34,6 +37,12 @@ FILE *logfile = NULL; | ||
| 34 | int loglevel; | 37 | int loglevel; |
| 35 | const char *interp_prefix = CONFIG_QEMU_PREFIX "/qemu-i386"; | 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 | /* XXX: on x86 MAP_GROWSDOWN only works if ESP <= address + 32, so | 46 | /* XXX: on x86 MAP_GROWSDOWN only works if ESP <= address + 32, so |
| 38 | we allocate a bigger stack. Need a better solution, for example | 47 | we allocate a bigger stack. Need a better solution, for example |
| 39 | by remapping the process stack directly at the right place */ | 48 | by remapping the process stack directly at the right place */ |
| @@ -370,6 +379,13 @@ int main(int argc, char **argv) | @@ -370,6 +379,13 @@ int main(int argc, char **argv) | ||
| 370 | 379 | ||
| 371 | if (argc <= 1) | 380 | if (argc <= 1) |
| 372 | usage(); | 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 | loglevel = 0; | 389 | loglevel = 0; |
| 374 | optind = 1; | 390 | optind = 1; |
| 375 | for(;;) { | 391 | for(;;) { |