From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Dz0s2-00041Y-Mt for qemu-devel@nongnu.org; Sat, 30 Jul 2005 19:35:59 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Dz0ry-00040N-Cz for qemu-devel@nongnu.org; Sat, 30 Jul 2005 19:35:55 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Dz0rx-0003lA-7e for qemu-devel@nongnu.org; Sat, 30 Jul 2005 19:35:53 -0400 Received: from [65.74.133.11] (helo=mail.codesourcery.com) by monty-python.gnu.org with esmtp (TLS-1.0:DHE_RSA_3DES_EDE_CBC_SHA:24) (Exim 4.34) id 1Dz0ZN-0004NE-W4 for qemu-devel@nongnu.org; Sat, 30 Jul 2005 19:16:42 -0400 From: Paul Brook Subject: Re: [Qemu-devel] [Patch Submission] QEMU with GCC/Win32 Date: Sun, 31 Jul 2005 00:04:27 +0100 References: <42EBCA12.80603@steveperkins.net> <200507302013.22433.paul@codesourcery.com> <42EBD7E3.7090409@steveperkins.net> In-Reply-To: <42EBD7E3.7090409@steveperkins.net> MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_8dA7CkNQl+VuriO" Message-Id: <200507310004.28470.paul@codesourcery.com> Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, Fabrice Bellard --Boundary-00=_8dA7CkNQl+VuriO Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline > I'm not sure what you mean about the patch "not being necessary". I > haven't tried building with Cygwin, so I can't speak for that platform. > My build environment is MinGW with the MSYS shell (to avoid onerous > licensing issues and DLL dependencies), and I can assure that the patch > very much is necessary for the current release of QEMU with the current > release of MinGW. QEMU does compile fine on Win32 with GCC 3.4, but the > executable crashes immediately when you try to run it. By applying the > patch I just posted, you get an executable that compiles and runs > properly (I've been running a FreeBSD environment just fine with a build > from the 0.7.1 patch I just posted). "sledgehammer" and "nut" spring to mind :-) The attached patch is sufficient to get qemu working on win32 when compiled with gcc3.4. I've successfully booted a knoppix CD inside qemu on a windows host with this patch. The problem was that gcc is choosing inconvenient names for static local variables. These symbols are never supposed to be seen outside the compiler, so it's allowed to change these at random. The solution is to use explicitly specify the asm name for the variable. Paul --Boundary-00=_8dA7CkNQl+VuriO Content-Type: text/x-diff; charset="iso-8859-1"; name="patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="patch" Index: exec-all.h =================================================================== RCS file: /cvsroot/qemu/qemu/exec-all.h,v retrieving revision 1.34 diff -u -p -r1.34 exec-all.h --- exec-all.h 24 Jul 2005 14:14:53 -0000 1.34 +++ exec-all.h 30 Jul 2005 22:56:09 -0000 @@ -320,13 +320,16 @@ TranslationBlock *tb_find_pc(unsigned lo #define ASM_PREVIOUS_SECTION ".previous\n" #endif +#define ASM_OP_LABEL_NAME(n, opname) \ + ASM_NAME(__op_label) #n "." ASM_NAME(opname) + #if defined(__powerpc__) /* we patch the jump instruction directly */ #define GOTO_TB(opname, tbparam, n)\ do {\ asm volatile (ASM_DATA_SECTION\ - ASM_NAME(__op_label) #n "." ASM_NAME(opname) ":\n"\ + ASM_OP_LABEL_NAME(n, opname) ":\n"\ ".long 1f\n"\ ASM_PREVIOUS_SECTION \ "b " ASM_NAME(__op_jmp) #n "\n"\ @@ -339,7 +342,7 @@ do {\ #define GOTO_TB(opname, tbparam, n)\ do {\ asm volatile (".section .data\n"\ - ASM_NAME(__op_label) #n "." ASM_NAME(opname) ":\n"\ + ASM_OP_LABEL_NAME(n, opname) ":\n"\ ".long 1f\n"\ ASM_PREVIOUS_SECTION \ "jmp " ASM_NAME(__op_jmp) #n "\n"\ @@ -353,7 +356,8 @@ do {\ #define GOTO_TB(opname, tbparam, n)\ do {\ static void __attribute__((unused)) *dummy ## n = &&dummy_label ## n;\ - static void __attribute__((unused)) *__op_label ## n = &&label ## n;\ + static void __attribute__((unused)) *__op_label ## n \ + __asm__(ASM_OP_LABEL_NAME(n, opname)) = &&label ## n;\ goto *(void *)(((TranslationBlock *)tbparam)->tb_next[n]);\ label ## n: ;\ dummy_label ## n: ;\ --Boundary-00=_8dA7CkNQl+VuriO--