From 46027c07de45d84441b40cc2db675efd29588af0 Mon Sep 17 00:00:00 2001 From: bellard Date: Thu, 8 Nov 2007 13:56:19 +0000 Subject: [PATCH] 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 --- linux-user/main.c | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/linux-user/main.c b/linux-user/main.c index 6fe51107c2..f80000f2f5 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -45,12 +45,20 @@ const char interp[] __attribute__((section(".interp"))) = "/lib/ld-linux.so.2"; /* for recent libc, we add these dummy symbols which are not declared when generating a linked object (bug in ld ?) */ #if (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) && !defined(CONFIG_STATIC) -long __preinit_array_start[0]; -long __preinit_array_end[0]; -long __init_array_start[0]; -long __init_array_end[0]; -long __fini_array_start[0]; -long __fini_array_end[0]; +asm(".globl __preinit_array_start\n" + ".globl __preinit_array_end\n" + ".globl __init_array_start\n" + ".globl __init_array_end\n" + ".globl __fini_array_start\n" + ".globl __fini_array_end\n" + ".section \".rodata\"\n" + "__preinit_array_start:\n" + "__preinit_array_end:\n" + "__init_array_start:\n" + "__init_array_end:\n" + "__fini_array_start:\n" + "__fini_array_end:\n" + ".long 0\n"); #endif /* XXX: on x86 MAP_GROWSDOWN only works if ESP <= address + 32, so @@ -1975,6 +1983,23 @@ int main(int argc, char **argv) /* Scan interp_prefix dir for replacement files. */ init_paths(interp_prefix); +#if defined(TARGET_I386) + /* must be done before cpu_init() for x86 XXX: suppress this hack + by adding a new parameter to cpu_init and by suppressing + cpu_xxx_register() */ + if (cpu_model == NULL) { +#ifdef TARGET_X86_64 + cpu_model = "qemu64"; +#else + cpu_model = "qemu32"; +#endif + } + if (x86_find_cpu_by_name(cpu_model)) { + fprintf(stderr, "Unable to find x86 CPU definition\n"); + exit(1); + } +#endif + /* NOTE: we need to init the CPU at this stage to get qemu_host_page_size */ env = cpu_init(); -- GitLab