From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1DXhGY-0005Jo-KU for qemu-devel@nongnu.org; Mon, 16 May 2005 11:12:22 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1DXd3s-0005jM-7X for qemu-devel@nongnu.org; Mon, 16 May 2005 06:43:04 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DXcAq-0001hj-PL for qemu-devel@nongnu.org; Mon, 16 May 2005 05:46:10 -0400 Received: from [213.146.154.40] (helo=pentafluge.infradead.org) by monty-python.gnu.org with esmtp (TLS-1.0:DHE_RSA_3DES_EDE_CBC_SHA:24) (Exim 4.34) id 1DXcFY-0008LE-OQ for qemu-devel@nongnu.org; Mon, 16 May 2005 05:51:00 -0400 Received: from shinybook.infradead.org ([81.187.226.99]) by pentafluge.infradead.org with esmtpsa (Exim 4.43 #1 (Red Hat Linux)) id 1DXc7y-0005S3-Rp for qemu-devel@nongnu.org; Mon, 16 May 2005 10:43:11 +0100 Subject: Re: [Qemu-devel] [patch] gcc4 host support From: David Woodhouse In-Reply-To: <200505112204.10204.paul@codesourcery.com> References: <200505112204.10204.paul@codesourcery.com> Content-Type: text/plain Date: Mon, 16 May 2005 10:41:31 +0100 Message-Id: <1116236492.25594.23.camel@localhost.localdomain> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit 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 On Wed, 2005-05-11 at 22:04 +0100, Paul Brook wrote: > My solution is to search the function for the "ret" instruction and replace > them with a jmp to the next block of code. On RISC targets this would be > easy. About this easy, in fact... --- qemu/dyngen.c.x 2005-05-16 10:30:43.000000000 +0100 +++ qemu/dyngen.c 2005-05-16 10:32:41.000000000 +0100 @@ -1996,6 +1996,9 @@ void gen_code(const char *name, host_ulo int retpos; int exit_addrs[MAX_EXITS]; #endif +#if defined(HOST_PPC) + uint8_t *blr_addr = NULL; +#endif /* Compute exact size excluding prologue and epilogue instructions. * Increment start_offset to skip epilogue instructions, then compute @@ -2018,9 +2021,23 @@ void gen_code(const char *name, host_ulo p = (void *)(p_end - 4); if (p == p_start) error("empty code for %s", name); - if (get32((uint32_t *)p) != 0x4e800020) - error("blr expected at the end of %s", name); - copy_size = p - p_start; + if (get32((uint32_t *)p) == 0x4e800020) { + copy_size = p - p_start; /* blr at end */ + } else { + /* Find the blr and note its address so that we + can emit code to rewrite it to a branch. */ + do { + p -= 4; + + if (get32((uint32_t *)p) == 0x4e800020) { + blr_addr = p; + copy_size = p_end - p_start; + break; + } + } while (p > p_start); + if (p == p_start) + error("blr expected in %s", name); + } } #elif defined(HOST_S390) { @@ -2633,6 +2650,9 @@ void gen_code(const char *name, host_ulo #else #error unsupport object format #endif + if (blr_addr) + fprintf(outfile, " *(uint32_t *)(gen_code_ptr + %d) = 0x48000000 | %d;\n", + blr_addr - p_start, p_end - blr_addr); } #elif defined(HOST_S390) { -- dwmw2