Commit e936243acad7a657d26560d16a1cb2a505936c2d
1 parent
f0b3f3ae
A branch insn must not overwrite the branch target before relocation.
When a branch to label is translated it generates a reloc that is filled in when the label is translated. However, when handling an exception and searching for the pc we abort the translation early and we sometimes translate the branch but not the corresponding label and so no relocation is done. When the block is executed again the branch points to no-where. It seems tcg/sparc/ is going to suffer from the same issue. git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4547 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
14 additions
and
3 deletions
tcg/arm/tcg-target.c
... | ... | @@ -78,8 +78,8 @@ static void patch_reloc(uint8_t *code_ptr, int type, |
78 | 78 | tcg_abort(); |
79 | 79 | |
80 | 80 | case R_ARM_PC24: |
81 | - *(uint32_t *) code_ptr |= | |
82 | - ((value - ((tcg_target_long) code_ptr + 8)) >> 2) & 0xffffff; | |
81 | + *(uint32_t *) code_ptr |= (*(uint32_t *) code_ptr & 0xff000000) | | |
82 | + (((value - ((tcg_target_long) code_ptr + 8)) >> 2) & 0xffffff); | |
83 | 83 | break; |
84 | 84 | } |
85 | 85 | } |
... | ... | @@ -272,6 +272,17 @@ static inline void tcg_out_b(TCGContext *s, int cond, int32_t offset) |
272 | 272 | (((offset - 8) >> 2) & 0x00ffffff)); |
273 | 273 | } |
274 | 274 | |
275 | +static inline void tcg_out_b_noaddr(TCGContext *s, int cond) | |
276 | +{ | |
277 | +#ifdef WORDS_BIGENDIAN | |
278 | + tcg_out8(s, (cond << 4) | 0x0a); | |
279 | + s->code_ptr += 3; | |
280 | +#else | |
281 | + s->code_ptr += 3; | |
282 | + tcg_out8(s, (cond << 4) | 0x0a); | |
283 | +#endif | |
284 | +} | |
285 | + | |
275 | 286 | static inline void tcg_out_bl(TCGContext *s, int cond, int32_t offset) |
276 | 287 | { |
277 | 288 | tcg_out32(s, (cond << 28) | 0x0b000000 | |
... | ... | @@ -734,7 +745,7 @@ static inline void tcg_out_goto_label(TCGContext *s, int cond, int label_index) |
734 | 745 | } else { |
735 | 746 | /* Probably this should be preferred even for COND_AL... */ |
736 | 747 | tcg_out_reloc(s, s->code_ptr, R_ARM_PC24, label_index, 31337); |
737 | - tcg_out_b(s, cond, 8); | |
748 | + tcg_out_b_noaddr(s, cond); | |
738 | 749 | } |
739 | 750 | } |
740 | 751 | ... | ... |