Search
lxdream.org :: lxdream :: r593:6c710c7c6835
lxdream 0.9.1
released Jun 29
Download Now
changeset593:6c710c7c6835
parent592:4343cbfdd21b
child594:6118deafd705
authornkeynes
dateThu Jan 17 21:26:58 2008 +0000 (16 years ago)
Fix block overruns from long epilogues
src/sh4/sh4trans.c
src/sh4/sh4trans.h
src/sh4/sh4x86.c
src/sh4/sh4x86.in
1.1 --- a/src/sh4/sh4trans.c Thu Jan 17 10:17:32 2008 +0000
1.2 +++ b/src/sh4/sh4trans.c Thu Jan 17 21:26:58 2008 +0000
1.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.26
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 +0000
2.2 +++ b/src/sh4/sh4trans.h Thu Jan 17 21:26:58 2008 +0000
2.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.8
2.9 typedef void (*unwind_thunk_t)(void);
2.10
3.1 --- a/src/sh4/sh4x86.c Thu Jan 17 10:17:32 2008 +0000
3.2 +++ b/src/sh4/sh4x86.c Thu Jan 17 21:26:58 2008 +0000
3.3 @@ -359,6 +359,12 @@
3.4 #endif
3.5 #endif
3.6
3.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 code
3.15 */
4.1 --- a/src/sh4/sh4x86.in Thu Jan 17 10:17:32 2008 +0000
4.2 +++ b/src/sh4/sh4x86.in Thu Jan 17 21:26:58 2008 +0000
4.3 @@ -359,6 +359,12 @@
4.4 #endif
4.5 #endif
4.6
4.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 code
4.15 */
.