Commit 623e265c6b1ad09fccecaa53f8c8a1fd572c54c7
1 parent
b2a5160c
Simplify TCG relocation bugfix.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3974 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
5 changed files
with
12 additions
and
17 deletions
tcg/i386/tcg-target.c
tcg/tcg.c
| ... | ... | @@ -97,9 +97,9 @@ void tcg_out_reloc(TCGContext *s, uint8_t *code_ptr, int type, |
| 97 | 97 | |
| 98 | 98 | l = &s->labels[label_index]; |
| 99 | 99 | if (l->has_value) { |
| 100 | - /* FIXME: This is wrong. We can not resolve the relocation | |
| 101 | - immediately because the caller has not yet written the | |
| 102 | - initial value. */ | |
| 100 | + /* FIXME: This may break relocations on RISC targets that | |
| 101 | + modify instruction fields in place. The caller may not have | |
| 102 | + written the initial value. */ | |
| 103 | 103 | patch_reloc(code_ptr, type, l->u.value + addend); |
| 104 | 104 | } else { |
| 105 | 105 | /* add a new relocation entry */ |
| ... | ... | @@ -1810,16 +1810,11 @@ int dyngen_code(TCGContext *s, uint8_t *gen_code_buf) |
| 1810 | 1810 | return s->code_ptr - gen_code_buf; |
| 1811 | 1811 | } |
| 1812 | 1812 | |
| 1813 | -static uint8_t *dummy_code_buf; | |
| 1814 | - | |
| 1815 | 1813 | /* Return the index of the micro operation such as the pc after is < |
| 1816 | - offset bytes from the start of the TB. | |
| 1817 | - We have to use a dummy code buffer here to avoid clobbering the | |
| 1818 | - oringinal code. Because we terminate code generation part way through | |
| 1819 | - we can end up with unresolved relocations. Return -1 if not found. */ | |
| 1820 | -int dyngen_code_search_pc(TCGContext *s, long offset) | |
| 1814 | + offset bytes from the start of the TB. The contents of gen_code_buf must | |
| 1815 | + not be changed, though writing the same values is ok. | |
| 1816 | + Return -1 if not found. */ | |
| 1817 | +int dyngen_code_search_pc(TCGContext *s, uint8_t *gen_code_buf, long offset) | |
| 1821 | 1818 | { |
| 1822 | - if (!dummy_code_buf) | |
| 1823 | - dummy_code_buf = qemu_malloc(code_gen_max_block_size()); | |
| 1824 | - return tcg_gen_code_common(s, dummy_code_buf, offset); | |
| 1819 | + return tcg_gen_code_common(s, gen_code_buf, offset); | |
| 1825 | 1820 | } | ... | ... |
tcg/tcg.h
| ... | ... | @@ -257,7 +257,7 @@ void tcg_context_init(TCGContext *s); |
| 257 | 257 | void tcg_func_start(TCGContext *s); |
| 258 | 258 | |
| 259 | 259 | int dyngen_code(TCGContext *s, uint8_t *gen_code_buf); |
| 260 | -int dyngen_code_search_pc(TCGContext *s, long offset); | |
| 260 | +int dyngen_code_search_pc(TCGContext *s, uint8_t *gen_code_buf, long offset); | |
| 261 | 261 | |
| 262 | 262 | void tcg_set_frame(TCGContext *s, int reg, |
| 263 | 263 | tcg_target_long start, tcg_target_long size); | ... | ... |
tcg/x86_64/tcg-target.c
translate-all.c
| ... | ... | @@ -187,7 +187,7 @@ int cpu_restore_state(TranslationBlock *tb, |
| 187 | 187 | s->tb_jmp_offset = NULL; |
| 188 | 188 | s->tb_next = tb->tb_next; |
| 189 | 189 | #endif |
| 190 | - j = dyngen_code_search_pc(s, searched_pc - tc_ptr); | |
| 190 | + j = dyngen_code_search_pc(s, (uint8_t *)tc_ptr, searched_pc - tc_ptr); | |
| 191 | 191 | if (j < 0) |
| 192 | 192 | return -1; |
| 193 | 193 | /* now find start of instruction before */ | ... | ... |