fixed a very nasty bug where the runtime stack/heap values appeared to simply be corrupted by the JIT initialization function. this probably never manifested in thiadmer's builds because the routine was broken at a higher level
This commit is contained in:
parent
748d000c02
commit
b2b2c1d961
@ -973,27 +973,25 @@ int AMXAPI amx_InitJIT(AMX *amx, void *reloc_table, void *native_code)
|
|||||||
memcpy(native_code, amx->base, ((AMX_HEADER *)(amx->base))->cod);
|
memcpy(native_code, amx->base, ((AMX_HEADER *)(amx->base))->cod);
|
||||||
hdr = (AMX_HEADER *)native_code;
|
hdr = (AMX_HEADER *)native_code;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* JIT rulz! (TM) */
|
/* JIT rulz! (TM) */
|
||||||
/* MP: added check for correct compilation */
|
/* MP: added check for correct compilation */
|
||||||
//Fixed bug (thanks T(+)rget)
|
//Fixed bug (thanks T(+)rget)
|
||||||
if ((res = asm_runJIT(amx->base, reloc_table, native_code)) == 0)
|
if ((res = asm_runJIT(amx->base, reloc_table, native_code)) == 0)
|
||||||
{
|
{
|
||||||
/* update the required memory size (the previous value was a
|
|
||||||
* conservative estimate, now we know the exact size)
|
|
||||||
*/
|
|
||||||
amx->code_size = (hdr->dat + hdr->stp + 3) & ~3;
|
|
||||||
/* The compiled code is relocatable, since only relative jumps are
|
/* The compiled code is relocatable, since only relative jumps are
|
||||||
* used for destinations within the generated code and absoulute
|
* used for destinations within the generated code and absoulute
|
||||||
* addresses for jumps into the runtime, which is fixed in memory.
|
* addresses for jumps into the runtime, which is fixed in memory.
|
||||||
*/
|
*/
|
||||||
amx->base = (unsigned char*) native_code;
|
amx->base = (unsigned char*) native_code;
|
||||||
amx->cip = hdr->cip;
|
amx->cip = hdr->cip;
|
||||||
amx->hea = hdr->hea;
|
/* also put a sentinel for strings at the top the stack */
|
||||||
amx->stp = hdr->stp - sizeof(cell);
|
*(cell *)((char*)native_code + hdr->dat + amx->stp - sizeof(cell)) = 0;
|
||||||
amx->hlw = hdr->hea;
|
/* update the required memory size (the previous value was a
|
||||||
/* also put a sentinel for strings at the top the stack */
|
* conservative estimate, now we know the exact size)
|
||||||
*(cell *)((char*)native_code + hdr->dat + hdr->stp - sizeof(cell)) = 0;
|
*/
|
||||||
amx->stk = amx->stp;
|
amx->code_size = (hdr->dat + amx->stp + sizeof(cell)) & ~3;
|
||||||
} /* if */
|
} /* if */
|
||||||
|
|
||||||
return (res == 0) ? AMX_ERR_NONE : AMX_ERR_INIT_JIT;
|
return (res == 0) ? AMX_ERR_NONE : AMX_ERR_INIT_JIT;
|
||||||
|
Loading…
Reference in New Issue
Block a user