RH9 fix - path patch


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@93 c046a42c-6fe2-441c-8c8c-71466251a162
diff --git a/linux-user/main.c b/linux-user/main.c
index 0c8480d..5c1dd8c 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -23,9 +23,6 @@
 #include <string.h>
 #include <errno.h>
 #include <unistd.h>
-#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)
-#include <sys/personality.h>
-#endif
 
 #include "qemu.h"
 
@@ -35,12 +32,22 @@
 
 FILE *logfile = NULL;
 int loglevel;
-const char *interp_prefix = CONFIG_QEMU_PREFIX "/qemu-i386";
+static const char *interp_prefix = CONFIG_QEMU_PREFIX;
 
 #ifdef __i386__
 /* Force usage of an ELF interpreter even if it is an ELF shared
    object ! */
 const char interp[] __attribute__((section(".interp"))) = "/lib/ld-linux.so.2";
+
+/* for recent libc, we add these dummies symbol which are not declared
+   when generating a linked object (bug in ld ?) */
+#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)
+long __init_array_start[0];
+long __init_array_end[0];
+long __fini_array_start[0];
+long __fini_array_end[0];
+#endif
+
 #endif
 
 /* XXX: on x86 MAP_GROWSDOWN only works if ESP <= address + 32, so
@@ -358,7 +365,7 @@
            DEBUG_LOGFILE,
            interp_prefix, 
            x86_stack_size);
-    exit(1);
+    _exit(1);
 }
 
 /* XXX: currently only used for async signals (see signal.c) */
@@ -379,12 +386,6 @@
     if (argc <= 1)
         usage();
 
-    /* Set personality to X86_LINUX.  May fail on unpatched kernels:
-       if so, they need to have munged paths themselves (eg. chroot,
-       hacked ld.so, whatever). */
-    if (personality(0x11) >= 0)
-	    interp_prefix = "";
-
     loglevel = 0;
     optind = 1;
     for(;;) {
@@ -423,7 +424,7 @@
         logfile = fopen(DEBUG_LOGFILE, "w");
         if (!logfile) {
             perror(DEBUG_LOGFILE);
-            exit(1);
+            _exit(1);
         }
         setvbuf(logfile, NULL, _IOLBF, 0);
     }
@@ -434,9 +435,12 @@
     /* Zero out image_info */
     memset(info, 0, sizeof(struct image_info));
 
-    if(elf_exec(interp_prefix, filename, argv+optind, environ, regs, info) != 0) {
+    /* Scan interp_prefix dir for replacement files. */
+    init_paths(interp_prefix);
+
+    if (elf_exec(filename, argv+optind, environ, regs, info) != 0) {
 	printf("Error loading %s\n", filename);
-	exit(1);
+	_exit(1);
     }
     
     if (loglevel) {