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 _______________________________________________ Qemu-devel mailing list Qemu-devel@nongnu.org http://lists.nongnu.org/mailman/listinfo/qemu-devel