Commit 46027c07de45d84441b40cc2db675efd29588af0
1 parent
a049de61
added -cpu option for x86 - fixed glibc hack in case the global variables are moved
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3548 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
31 additions
and
6 deletions
linux-user/main.c
| @@ -45,12 +45,20 @@ const char interp[] __attribute__((section(".interp"))) = "/lib/ld-linux.so.2"; | @@ -45,12 +45,20 @@ const char interp[] __attribute__((section(".interp"))) = "/lib/ld-linux.so.2"; | ||
| 45 | /* for recent libc, we add these dummy symbols which are not declared | 45 | /* for recent libc, we add these dummy symbols which are not declared |
| 46 | when generating a linked object (bug in ld ?) */ | 46 | when generating a linked object (bug in ld ?) */ |
| 47 | #if (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) && !defined(CONFIG_STATIC) | 47 | #if (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) && !defined(CONFIG_STATIC) |
| 48 | -long __preinit_array_start[0]; | ||
| 49 | -long __preinit_array_end[0]; | ||
| 50 | -long __init_array_start[0]; | ||
| 51 | -long __init_array_end[0]; | ||
| 52 | -long __fini_array_start[0]; | ||
| 53 | -long __fini_array_end[0]; | 48 | +asm(".globl __preinit_array_start\n" |
| 49 | + ".globl __preinit_array_end\n" | ||
| 50 | + ".globl __init_array_start\n" | ||
| 51 | + ".globl __init_array_end\n" | ||
| 52 | + ".globl __fini_array_start\n" | ||
| 53 | + ".globl __fini_array_end\n" | ||
| 54 | + ".section \".rodata\"\n" | ||
| 55 | + "__preinit_array_start:\n" | ||
| 56 | + "__preinit_array_end:\n" | ||
| 57 | + "__init_array_start:\n" | ||
| 58 | + "__init_array_end:\n" | ||
| 59 | + "__fini_array_start:\n" | ||
| 60 | + "__fini_array_end:\n" | ||
| 61 | + ".long 0\n"); | ||
| 54 | #endif | 62 | #endif |
| 55 | 63 | ||
| 56 | /* XXX: on x86 MAP_GROWSDOWN only works if ESP <= address + 32, so | 64 | /* XXX: on x86 MAP_GROWSDOWN only works if ESP <= address + 32, so |
| @@ -1975,6 +1983,23 @@ int main(int argc, char **argv) | @@ -1975,6 +1983,23 @@ int main(int argc, char **argv) | ||
| 1975 | /* Scan interp_prefix dir for replacement files. */ | 1983 | /* Scan interp_prefix dir for replacement files. */ |
| 1976 | init_paths(interp_prefix); | 1984 | init_paths(interp_prefix); |
| 1977 | 1985 | ||
| 1986 | +#if defined(TARGET_I386) | ||
| 1987 | + /* must be done before cpu_init() for x86 XXX: suppress this hack | ||
| 1988 | + by adding a new parameter to cpu_init and by suppressing | ||
| 1989 | + cpu_xxx_register() */ | ||
| 1990 | + if (cpu_model == NULL) { | ||
| 1991 | +#ifdef TARGET_X86_64 | ||
| 1992 | + cpu_model = "qemu64"; | ||
| 1993 | +#else | ||
| 1994 | + cpu_model = "qemu32"; | ||
| 1995 | +#endif | ||
| 1996 | + } | ||
| 1997 | + if (x86_find_cpu_by_name(cpu_model)) { | ||
| 1998 | + fprintf(stderr, "Unable to find x86 CPU definition\n"); | ||
| 1999 | + exit(1); | ||
| 2000 | + } | ||
| 2001 | +#endif | ||
| 2002 | + | ||
| 1978 | /* NOTE: we need to init the CPU at this stage to get | 2003 | /* NOTE: we need to init the CPU at this stage to get |
| 1979 | qemu_host_page_size */ | 2004 | qemu_host_page_size */ |
| 1980 | env = cpu_init(); | 2005 | env = cpu_init(); |