Skip to content

Commit d034fb1

Browse files
authored
x86_64: fix near jump check (#352)
* x86_64: fix near jump check
1 parent acf9f8f commit d034fb1

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

sljit_src/sljitNativeX86_common.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,9 @@ static sljit_u8* detect_near_jump_type(struct sljit_jump *jump, sljit_u8 *code_p
681681
sljit_s32 short_jump;
682682
sljit_uw label_addr;
683683
sljit_uw jump_addr;
684+
#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
685+
sljit_uw rel_size;
686+
#endif /* SLJIT_CONFIG_X86_64 */
684687

685688
jump_addr = (sljit_uw)code_ptr;
686689
if (!(jump->flags & JUMP_ADDR)) {
@@ -692,7 +695,8 @@ static sljit_u8* detect_near_jump_type(struct sljit_jump *jump, sljit_u8 *code_p
692695
label_addr = jump->u.target - (sljit_uw)executable_offset;
693696

694697
#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
695-
if ((sljit_sw)(label_addr - (jump_addr + 6)) > HALFWORD_MAX || (sljit_sw)(label_addr - (jump_addr + 5)) < HALFWORD_MIN)
698+
rel_size = (type < SLJIT_JUMP) ? 6 : 5;
699+
if ((sljit_sw)(label_addr - (jump_addr + rel_size)) > HALFWORD_MAX || (sljit_sw)(label_addr - (jump_addr + rel_size)) < HALFWORD_MIN)
696700
return detect_far_jump_type(jump, code_ptr);
697701
#endif /* SLJIT_CONFIG_X86_64 */
698702

0 commit comments

Comments
 (0)