revision 593:6c710c7c6835
summary |
tree |
shortlog |
changelog |
graph |
changeset |
raw | bz2 | zip | gz changeset | 593:6c710c7c6835 |
parent | 592:4343cbfdd21b |
child | 594:6118deafd705 |
author | nkeynes |
date | Thu Jan 17 21:26:58 2008 +0000 (16 years ago) |
Fix block overruns from long epilogues
src/sh4/sh4trans.c | view | annotate | diff | log | ||
src/sh4/sh4trans.h | view | annotate | diff | log | ||
src/sh4/sh4x86.c | view | annotate | diff | log | ||
src/sh4/sh4x86.in | view | annotate | diff | log |
1.1 --- a/src/sh4/sh4trans.c Thu Jan 17 10:17:32 2008 +00001.2 +++ b/src/sh4/sh4trans.c Thu Jan 17 21:26:58 2008 +00001.3 @@ -88,6 +88,7 @@1.4 code = xlat_get_code_by_vma( sh4r.pc );1.5 if( code == NULL ) {1.6 code = sh4_translate_basic_block( sh4r.pc );1.7 +// xlat_check_integrity();1.8 }1.9 }1.10 code = code();1.11 @@ -152,21 +153,17 @@1.12 }1.13 } while( !done );1.14 pc += (done - 2);1.15 - if( eob - xlat_output < EPILOGUE_SIZE ) {1.16 + int epilogue_size = sh4_translate_end_block_size();1.17 + uint32_t recovery_size = sizeof(struct xlat_recovery_record)*xlat_recovery_posn;1.18 + uint32_t finalsize = xlat_output - block->code + epilogue_size + recovery_size;1.19 + if( eob - xlat_output < finalsize ) {1.20 uint8_t *oldstart = block->code;1.21 - block = xlat_extend_block( xlat_output - oldstart + EPILOGUE_SIZE );1.22 + block = xlat_extend_block( finalsize );1.23 xlat_output = block->code + (xlat_output - oldstart);1.24 }1.25 sh4_translate_end_block(pc);1.27 /* Write the recovery records onto the end of the code block */1.28 - uint32_t recovery_size = sizeof(struct xlat_recovery_record)*xlat_recovery_posn;1.29 - uint32_t finalsize = xlat_output - block->code + recovery_size;1.30 - if( finalsize > block->size ) {1.31 - uint8_t *oldstart = block->code;1.32 - block = xlat_extend_block( finalsize );1.33 - xlat_output = block->code + (xlat_output - oldstart);1.34 - }1.35 memcpy( xlat_output, xlat_recovery, recovery_size);1.36 block->recover_table_offset = xlat_output - (uint8_t *)block->code;1.37 block->recover_table_size = xlat_recovery_posn;
2.1 --- a/src/sh4/sh4trans.h Thu Jan 17 10:17:32 2008 +00002.2 +++ b/src/sh4/sh4trans.h Thu Jan 17 21:26:58 2008 +00002.3 @@ -87,6 +87,7 @@2.4 void sh4_translate_begin_block( sh4addr_t pc );2.5 uint32_t sh4_translate_instruction( sh4addr_t pc );2.6 void sh4_translate_end_block( sh4addr_t pc );2.7 +uint32_t sh4_translate_end_block_size();2.9 typedef void (*unwind_thunk_t)(void);
3.1 --- a/src/sh4/sh4x86.c Thu Jan 17 10:17:32 2008 +00003.2 +++ b/src/sh4/sh4x86.c Thu Jan 17 21:26:58 2008 +00003.3 @@ -359,6 +359,12 @@3.4 #endif3.5 #endif3.7 +uint32_t sh4_translate_end_block_size()3.8 +{3.9 + return EPILOGUE_SIZE + (sh4_x86.backpatch_posn*12);3.10 +}3.11 +3.12 +3.13 /**3.14 * Embed a breakpoint into the generated code3.15 */
4.1 --- a/src/sh4/sh4x86.in Thu Jan 17 10:17:32 2008 +00004.2 +++ b/src/sh4/sh4x86.in Thu Jan 17 21:26:58 2008 +00004.3 @@ -359,6 +359,12 @@4.4 #endif4.5 #endif4.7 +uint32_t sh4_translate_end_block_size()4.8 +{4.9 + return EPILOGUE_SIZE + (sh4_x86.backpatch_posn*12);4.10 +}4.11 +4.12 +4.13 /**4.14 * Embed a breakpoint into the generated code4.15 */
.