Skip to content

Commit 8e661d2

Browse files
authored
[DYNAREC] Always initialize jump table for DynaRec build (#3990)
If DynaRec is disabled by env var but enabled in rcfile, the initialize process will be: ``` LoadEnvVariables() NewBox64Context() -> dynarec=0, jump table not initialize ApplyEnvFileEntry() AllocLoadElfMemory() -> crash ``` I guess it's okay to always initilize the table.
1 parent 46459eb commit 8e661d2

1 file changed

Lines changed: 20 additions & 22 deletions

File tree

src/custommem.c

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3155,29 +3155,27 @@ void init_custommem_helper(box64context_t* ctx)
31553155
rb_set(blockstree, (uintptr_t)p_blocks[i].block, (uintptr_t)p_blocks[i].block+p_blocks[i].size, i);
31563156
memprot = rbtree_init("memprot");
31573157
#ifdef DYNAREC
3158-
if(BOX64ENV(dynarec)) {
3159-
#ifdef JMPTABL_SHIFT4
3160-
for(int i=0; i<(1<<JMPTABL_SHIFT4); ++i)
3161-
box64_jmptbl4[i] = box64_jmptbldefault3;
3162-
for(int i=0; i<(1<<JMPTABL_SHIFT3); ++i) {
3163-
box64_jmptbldefault3[i] = box64_jmptbldefault2;
3164-
box64_jmptbl_48[i] = box64_jmptbldefault2;
3165-
}
3166-
box64_jmptbl4[0] = box64_jmptbl_48;
3167-
#else
3168-
for(int i=0; i<(1<<JMPTABL_SHIFT3); ++i) {
3169-
box64_jmptbl3[i] = box64_jmptbldefault2;
3170-
box64_jmptbl_48[i] = box64_jmptbldefault1;
3171-
}
3172-
box64_jmptbl3[0] = box64_jmptbl_48;
3173-
#endif
3174-
for(int i=0; i<(1<<JMPTABL_SHIFT2); ++i)
3175-
box64_jmptbldefault2[i] = box64_jmptbldefault1;
3176-
for(int i=0; i<(1<<JMPTABL_SHIFT1); ++i)
3177-
box64_jmptbldefault1[i] = box64_jmptbldefault0;
3178-
for(int i=0; i<(1<<JMPTABL_SHIFT0); ++i)
3179-
box64_jmptbldefault0[i] = (uintptr_t)native_next;
3158+
#ifdef JMPTABL_SHIFT4
3159+
for(int i=0; i<(1<<JMPTABL_SHIFT4); ++i)
3160+
box64_jmptbl4[i] = box64_jmptbldefault3;
3161+
for(int i=0; i<(1<<JMPTABL_SHIFT3); ++i) {
3162+
box64_jmptbldefault3[i] = box64_jmptbldefault2;
3163+
box64_jmptbl_48[i] = box64_jmptbldefault2;
31803164
}
3165+
box64_jmptbl4[0] = box64_jmptbl_48;
3166+
#else
3167+
for(int i=0; i<(1<<JMPTABL_SHIFT3); ++i) {
3168+
box64_jmptbl3[i] = box64_jmptbldefault2;
3169+
box64_jmptbl_48[i] = box64_jmptbldefault1;
3170+
}
3171+
box64_jmptbl3[0] = box64_jmptbl_48;
3172+
#endif
3173+
for(int i=0; i<(1<<JMPTABL_SHIFT2); ++i)
3174+
box64_jmptbldefault2[i] = box64_jmptbldefault1;
3175+
for(int i=0; i<(1<<JMPTABL_SHIFT1); ++i)
3176+
box64_jmptbldefault1[i] = box64_jmptbldefault0;
3177+
for(int i=0; i<(1<<JMPTABL_SHIFT0); ++i)
3178+
box64_jmptbldefault0[i] = (uintptr_t)native_next;
31813179
lockaddress = kh_init(lockaddress);
31823180
rbt_dynmem = rbtree_init("rbt_dynmem");
31833181
#endif

0 commit comments

Comments
 (0)