Simplify TCG relocation bugfix.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3974 c046a42c-6fe2-441c-8c8c-71466251a162
diff --git a/tcg/tcg.c b/tcg/tcg.c
index 4ddc62f..a206e53 100644
--- a/tcg/tcg.c
+++ b/tcg/tcg.c
@@ -97,9 +97,9 @@
l = &s->labels[label_index];
if (l->has_value) {
- /* FIXME: This is wrong. We can not resolve the relocation
- immediately because the caller has not yet written the
- initial value. */
+ /* FIXME: This may break relocations on RISC targets that
+ modify instruction fields in place. The caller may not have
+ written the initial value. */
patch_reloc(code_ptr, type, l->u.value + addend);
} else {
/* add a new relocation entry */
@@ -1810,16 +1810,11 @@
return s->code_ptr - gen_code_buf;
}
-static uint8_t *dummy_code_buf;
-
/* Return the index of the micro operation such as the pc after is <
- offset bytes from the start of the TB.
- We have to use a dummy code buffer here to avoid clobbering the
- oringinal code. Because we terminate code generation part way through
- we can end up with unresolved relocations. Return -1 if not found. */
-int dyngen_code_search_pc(TCGContext *s, long offset)
+ offset bytes from the start of the TB. The contents of gen_code_buf must
+ not be changed, though writing the same values is ok.
+ Return -1 if not found. */
+int dyngen_code_search_pc(TCGContext *s, uint8_t *gen_code_buf, long offset)
{
- if (!dummy_code_buf)
- dummy_code_buf = qemu_malloc(code_gen_max_block_size());
- return tcg_gen_code_common(s, dummy_code_buf, offset);
+ return tcg_gen_code_common(s, gen_code_buf, offset);
}