qemu/qemu-0.8.0-gcc4_ppc.patch

50 lines
1.6 KiB
Diff

--- dyngen.c.orig 2005-09-11 01:11:34.117968136 +0200
+++ dyngen.c 2005-09-11 01:14:16.128338816 +0200
@@ -1996,6 +1996,9 @@
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
@@ -2020,9 +2023,23 @@
if (p == p_start)
error("empty code for %s", name);
insn = get32((uint32_t *)p);
- if (insn != 0x4e800020 && (insn & 0xfc000002) != 0x48000000)
- error("blr or b 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 the end of %s", name);
+ }
}
#elif defined(HOST_S390)
{
@@ -2635,6 +2652,9 @@
#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)
{