qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: David Woodhouse <dwmw2@infradead.org>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [patch] gcc4 host support
Date: Mon, 16 May 2005 10:41:31 +0100	[thread overview]
Message-ID: <1116236492.25594.23.camel@localhost.localdomain> (raw)
In-Reply-To: <200505112204.10204.paul@codesourcery.com>

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

  parent reply	other threads:[~2005-05-16 15:12 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-05-11 21:04 [Qemu-devel] [patch] gcc4 host support Paul Brook
2005-05-12 17:00 ` Paul Brook
2005-05-12 22:13   ` Pascal Terjan
2005-05-12 22:25     ` Paul Brook
2005-05-14  7:55   ` Filip Navara
2005-05-14 11:53     ` Paul Brook
2005-05-14 11:56       ` Filip Navara
2005-06-17  4:30   ` [Qemu-devel] Fedora 4 + GCC4 + Qemu WAS: " Darryl Dixon
2005-06-17 12:45     ` Paul Brook
     [not found]       ` <1119013084.5187.4.camel@darrylsfc3box>
2005-06-17 13:02         ` Paul Brook
2005-06-17 22:18           ` David Woodhouse
2005-06-20  1:18           ` Darryl Dixon
2005-05-16  9:41 ` David Woodhouse [this message]
2005-05-17 20:46   ` [Qemu-devel] " Paul Brook
2005-05-18 10:06     ` Herbert Poetzl
2005-05-18 16:02       ` Paul Brook
2005-05-18 16:10         ` David Woodhouse
2005-05-18 19:29       ` John Hogerhuis
2005-05-18 20:48         ` Paul Brook
2005-05-18 20:55           ` David Woodhouse
2005-05-18 21:16             ` Paul Brook
2005-05-18 21:29             ` jeebs
2005-05-18 22:37               ` Paul Brook
2005-05-18 23:05                 ` Ian Rogers
2005-05-18 22:37               ` Ian Rogers
2005-05-19  7:23           ` Gwenole Beauchesne
2005-05-19 13:20             ` Paul Brook
2005-05-19 14:07               ` Gwenole Beauchesne
2005-05-19 15:44                 ` Paul Brook
2005-05-19 18:14                   ` Thomas Steffen
2005-05-19 18:52                     ` Paul Brook
2005-05-19 19:38                       ` Tim Walker
2005-05-19 19:45                         ` Paul Brook
2005-05-19 21:03                       ` Thomas Steffen
2005-05-19 22:25                         ` John Hogerhuis
2005-05-20  9:59                           ` Thomas Steffen
2005-05-20 12:57                           ` Paul Brook
2005-05-19 16:18                 ` Ian Rogers
2005-05-19 13:47             ` McMullan, Jason

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1116236492.25594.23.camel@localhost.localdomain \
    --to=dwmw2@infradead.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).