"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/sljit/sljitNativeX86_common.c" between
pcre2-10.35.tar.bz2 and pcre2-10.36.tar.bz2

About: The PCRE2 library implements Perl compatible regular expression pattern matching. New future PCRE version with revised API.

sljitNativeX86_common.c  (pcre2-10.35.tar.bz2):sljitNativeX86_common.c  (pcre2-10.36.tar.bz2)
skipping to change at line 509 skipping to change at line 509
struct sljit_label *label; struct sljit_label *label;
struct sljit_jump *jump; struct sljit_jump *jump;
struct sljit_const *const_; struct sljit_const *const_;
struct sljit_put_label *put_label; struct sljit_put_label *put_label;
CHECK_ERROR_PTR(); CHECK_ERROR_PTR();
CHECK_PTR(check_sljit_generate_code(compiler)); CHECK_PTR(check_sljit_generate_code(compiler));
reverse_buf(compiler); reverse_buf(compiler);
/* Second code generation pass. */ /* Second code generation pass. */
code = (sljit_u8*)SLJIT_MALLOC_EXEC(compiler->size); code = (sljit_u8*)SLJIT_MALLOC_EXEC(compiler->size, compiler->exec_alloca tor_data);
PTR_FAIL_WITH_EXEC_IF(code); PTR_FAIL_WITH_EXEC_IF(code);
buf = compiler->buf; buf = compiler->buf;
code_ptr = code; code_ptr = code;
label = compiler->labels; label = compiler->labels;
jump = compiler->jumps; jump = compiler->jumps;
const_ = compiler->consts; const_ = compiler->consts;
put_label = compiler->put_labels; put_label = compiler->put_labels;
executable_offset = SLJIT_EXEC_OFFSET(code); executable_offset = SLJIT_EXEC_OFFSET(code);
skipping to change at line 560 skipping to change at line 560
break; break;
case 2: case 2:
const_->addr = ((sljit_uw)code_ptr) - siz eof(sljit_sw); const_->addr = ((sljit_uw)code_ptr) - siz eof(sljit_sw);
const_ = const_->next; const_ = const_->next;
break; break;
default: default:
SLJIT_ASSERT(*buf_ptr == 3); SLJIT_ASSERT(*buf_ptr == 3);
SLJIT_ASSERT(put_label->label); SLJIT_ASSERT(put_label->label);
put_label->addr = (sljit_uw)code_ptr; put_label->addr = (sljit_uw)code_ptr;
#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) #if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
code_ptr = generate_put_label_code(put_la bel, code_ptr, (sljit_uw)(SLJIT_ADD_EXEC_OFFSET(code, executable_offset) + put_l abel->label->size)); code_ptr = generate_put_label_code(put_la bel, code_ptr, (sljit_uw)SLJIT_ADD_EXEC_OFFSET(code, executable_offset) + put_la bel->label->size);
#endif #endif
put_label = put_label->next; put_label = put_label->next;
break; break;
} }
buf_ptr++; buf_ptr++;
} }
} while (buf_ptr < buf_end); } while (buf_ptr < buf_end);
SLJIT_ASSERT(buf_ptr == buf_end); SLJIT_ASSERT(buf_ptr == buf_end);
buf = buf->next; buf = buf->next;
} while (buf); } while (buf);
skipping to change at line 632 skipping to change at line 632
sljit_unaligned_store_s32((void*)(put_label->addr - sizeo f(sljit_s32)), (sljit_s32)put_label->label->addr); sljit_unaligned_store_s32((void*)(put_label->addr - sizeo f(sljit_s32)), (sljit_s32)put_label->label->addr);
} }
#endif #endif
put_label = put_label->next; put_label = put_label->next;
} }
compiler->error = SLJIT_ERR_COMPILED; compiler->error = SLJIT_ERR_COMPILED;
compiler->executable_offset = executable_offset; compiler->executable_offset = executable_offset;
compiler->executable_size = code_ptr - code; compiler->executable_size = code_ptr - code;
return (void*)(code + executable_offset);
code = (sljit_u8*)SLJIT_ADD_EXEC_OFFSET(code, executable_offset);
SLJIT_UPDATE_WX_FLAGS(code, (sljit_u8*)SLJIT_ADD_EXEC_OFFSET(code_ptr, ex
ecutable_offset), 1);
return (void*)code;
} }
SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_has_cpu_feature(sljit_s32 feature_type) SLJIT_API_FUNC_ATTRIBUTE sljit_s32 sljit_has_cpu_feature(sljit_s32 feature_type)
{ {
switch (feature_type) { switch (feature_type) {
case SLJIT_HAS_FPU: case SLJIT_HAS_FPU:
#ifdef SLJIT_IS_FPU_AVAILABLE #ifdef SLJIT_IS_FPU_AVAILABLE
return SLJIT_IS_FPU_AVAILABLE; return SLJIT_IS_FPU_AVAILABLE;
#elif (defined SLJIT_DETECT_SSE2 && SLJIT_DETECT_SSE2) #elif (defined SLJIT_DETECT_SSE2 && SLJIT_DETECT_SSE2)
if (cpu_has_sse2 == -1) if (cpu_has_sse2 == -1)
skipping to change at line 728 skipping to change at line 732
FAIL_IF(!inst); FAIL_IF(!inst);
INC_SIZE(4); INC_SIZE(4);
*inst++ = 0xf3; *inst++ = 0xf3;
*inst++ = 0x0f; *inst++ = 0x0f;
*inst++ = 0x1e; *inst++ = 0x1e;
#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
*inst = 0xfb; *inst = 0xfb;
#else #else
*inst = 0xfa; *inst = 0xfa;
#endif #endif
#else #else /* !SLJIT_CONFIG_X86_CET */
SLJIT_UNUSED_ARG(compiler); SLJIT_UNUSED_ARG(compiler);
#endif #endif /* SLJIT_CONFIG_X86_CET */
return SLJIT_SUCCESS; return SLJIT_SUCCESS;
} }
#if (defined SLJIT_CONFIG_X86_CET && SLJIT_CONFIG_X86_CET) && defined (__SHSTK__
)
static SLJIT_INLINE sljit_s32 emit_rdssp(struct sljit_compiler *compiler, sljit_ s32 reg) static SLJIT_INLINE sljit_s32 emit_rdssp(struct sljit_compiler *compiler, sljit_ s32 reg)
{ {
#if (defined SLJIT_CONFIG_X86_CET && SLJIT_CONFIG_X86_CET)
sljit_u8 *inst; sljit_u8 *inst;
sljit_s32 size; sljit_s32 size;
#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) #if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
size = 5; size = 5;
#else #else
size = 4; size = 4;
#endif #endif
inst = (sljit_u8*)ensure_buf(compiler, 1 + size); inst = (sljit_u8*)ensure_buf(compiler, 1 + size);
FAIL_IF(!inst); FAIL_IF(!inst);
INC_SIZE(size); INC_SIZE(size);
*inst++ = 0xf3; *inst++ = 0xf3;
#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) #if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
*inst++ = REX_W | (reg_map[reg] <= 7 ? 0 : REX_B); *inst++ = REX_W | (reg_map[reg] <= 7 ? 0 : REX_B);
#endif #endif
*inst++ = 0x0f; *inst++ = 0x0f;
*inst++ = 0x1e; *inst++ = 0x1e;
*inst = (0x3 << 6) | (0x1 << 3) | (reg_map[reg] & 0x7); *inst = (0x3 << 6) | (0x1 << 3) | (reg_map[reg] & 0x7);
#else
SLJIT_UNUSED_ARG(compiler);
SLJIT_UNUSED_ARG(reg);
#endif
return SLJIT_SUCCESS; return SLJIT_SUCCESS;
} }
static SLJIT_INLINE sljit_s32 emit_incssp(struct sljit_compiler *compiler, sljit _s32 reg) static SLJIT_INLINE sljit_s32 emit_incssp(struct sljit_compiler *compiler, sljit _s32 reg)
{ {
#if (defined SLJIT_CONFIG_X86_CET && SLJIT_CONFIG_X86_CET)
sljit_u8 *inst; sljit_u8 *inst;
sljit_s32 size; sljit_s32 size;
#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) #if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
size = 5; size = 5;
#else #else
size = 4; size = 4;
#endif #endif
inst = (sljit_u8*)ensure_buf(compiler, 1 + size); inst = (sljit_u8*)ensure_buf(compiler, 1 + size);
FAIL_IF(!inst); FAIL_IF(!inst);
INC_SIZE(size); INC_SIZE(size);
*inst++ = 0xf3; *inst++ = 0xf3;
#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) #if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
*inst++ = REX_W | (reg_map[reg] <= 7 ? 0 : REX_B); *inst++ = REX_W | (reg_map[reg] <= 7 ? 0 : REX_B);
#endif #endif
*inst++ = 0x0f; *inst++ = 0x0f;
*inst++ = 0xae; *inst++ = 0xae;
*inst = (0x3 << 6) | (0x5 << 3) | (reg_map[reg] & 0x7); *inst = (0x3 << 6) | (0x5 << 3) | (reg_map[reg] & 0x7);
#else
SLJIT_UNUSED_ARG(compiler);
SLJIT_UNUSED_ARG(reg);
#endif
return SLJIT_SUCCESS; return SLJIT_SUCCESS;
} }
#endif /* SLJIT_CONFIG_X86_CET && __SHSTK__ */
static SLJIT_INLINE sljit_s32 cpu_has_shadow_stack(void) static SLJIT_INLINE sljit_s32 cpu_has_shadow_stack(void)
{ {
#if (defined SLJIT_CONFIG_X86_CET && SLJIT_CONFIG_X86_CET) #if (defined SLJIT_CONFIG_X86_CET && SLJIT_CONFIG_X86_CET) && defined (__SHSTK__ )
return _get_ssp() != 0; return _get_ssp() != 0;
#else #else /* !SLJIT_CONFIG_X86_CET || !__SHSTK__ */
return 0; return 0;
#endif #endif /* SLJIT_CONFIG_X86_CET && __SHSTK__ */
} }
static SLJIT_INLINE sljit_s32 adjust_shadow_stack(struct sljit_compiler *compile r, static SLJIT_INLINE sljit_s32 adjust_shadow_stack(struct sljit_compiler *compile r,
sljit_s32 src, sljit_sw srcw, sljit_s32 base, sljit_sw disp) sljit_s32 src, sljit_sw srcw, sljit_s32 base, sljit_sw disp)
{ {
#if (defined SLJIT_CONFIG_X86_CET && SLJIT_CONFIG_X86_CET) #if (defined SLJIT_CONFIG_X86_CET && SLJIT_CONFIG_X86_CET) && defined (__SHSTK__
sljit_u8 *inst; )
sljit_u8 *inst, *jz_after_cmp_inst;
sljit_uw size_jz_after_cmp_inst;
sljit_s32 size_before_rdssp_inst = compiler->size; sljit_uw size_before_rdssp_inst = compiler->size;
/* Generate "RDSSP TMP_REG1". */ /* Generate "RDSSP TMP_REG1". */
FAIL_IF(emit_rdssp(compiler, TMP_REG1)); FAIL_IF(emit_rdssp(compiler, TMP_REG1));
/* Load return address on shadow stack into TMP_REG1. */ /* Load return address on shadow stack into TMP_REG1. */
#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
SLJIT_ASSERT(reg_map[TMP_REG1] == 5); SLJIT_ASSERT(reg_map[TMP_REG1] == 5);
/* Hand code unsupported "mov 0x0(%ebp),%ebp". */ /* Hand code unsupported "mov 0x0(%ebp),%ebp". */
inst = (sljit_u8*)ensure_buf(compiler, 1 + 3); inst = (sljit_u8*)ensure_buf(compiler, 1 + 3);
skipping to change at line 842 skipping to change at line 841
/* Compare return address against TMP_REG1. */ /* Compare return address against TMP_REG1. */
FAIL_IF(emit_cmp_binary (compiler, TMP_REG1, 0, src, srcw)); FAIL_IF(emit_cmp_binary (compiler, TMP_REG1, 0, src, srcw));
/* Generate JZ to skip shadow stack ajdustment when shadow /* Generate JZ to skip shadow stack ajdustment when shadow
stack matches normal stack. */ stack matches normal stack. */
inst = (sljit_u8*)ensure_buf(compiler, 1 + 2); inst = (sljit_u8*)ensure_buf(compiler, 1 + 2);
FAIL_IF(!inst); FAIL_IF(!inst);
INC_SIZE(2); INC_SIZE(2);
*inst++ = get_jump_code(SLJIT_EQUAL) - 0x10; *inst++ = get_jump_code(SLJIT_EQUAL) - 0x10;
sljit_uw size_jz_after_cmp_inst = compiler->size; size_jz_after_cmp_inst = compiler->size;
sljit_u8 *jz_after_cmp_inst = inst; jz_after_cmp_inst = inst;
#if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64) #if (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)
/* REX_W is not necessary. */ /* REX_W is not necessary. */
compiler->mode32 = 1; compiler->mode32 = 1;
#endif #endif
/* Load 1 into TMP_REG1. */ /* Load 1 into TMP_REG1. */
EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_IMM, 1); EMIT_MOV(compiler, TMP_REG1, 0, SLJIT_IMM, 1);
/* Generate "INCSSP TMP_REG1". */ /* Generate "INCSSP TMP_REG1". */
FAIL_IF(emit_incssp(compiler, TMP_REG1)); FAIL_IF(emit_incssp(compiler, TMP_REG1));
/* Jump back to "RDSSP TMP_REG1" to check shadow stack again. */ /* Jump back to "RDSSP TMP_REG1" to check shadow stack again. */
inst = (sljit_u8*)ensure_buf(compiler, 1 + 2); inst = (sljit_u8*)ensure_buf(compiler, 1 + 2);
FAIL_IF(!inst); FAIL_IF(!inst);
INC_SIZE(2); INC_SIZE(2);
*inst++ = JMP_i8; *inst++ = JMP_i8;
*inst = size_before_rdssp_inst - compiler->size; *inst = size_before_rdssp_inst - compiler->size;
*jz_after_cmp_inst = compiler->size - size_jz_after_cmp_inst; *jz_after_cmp_inst = compiler->size - size_jz_after_cmp_inst;
#else /* SLJIT_CONFIG_X86_CET */ #else /* !SLJIT_CONFIG_X86_CET || !__SHSTK__ */
SLJIT_UNUSED_ARG(compiler); SLJIT_UNUSED_ARG(compiler);
SLJIT_UNUSED_ARG(src); SLJIT_UNUSED_ARG(src);
SLJIT_UNUSED_ARG(srcw); SLJIT_UNUSED_ARG(srcw);
SLJIT_UNUSED_ARG(base); SLJIT_UNUSED_ARG(base);
SLJIT_UNUSED_ARG(disp); SLJIT_UNUSED_ARG(disp);
#endif /* SLJIT_CONFIG_X86_CET */ #endif /* SLJIT_CONFIG_X86_CET && __SHSTK__ */
return SLJIT_SUCCESS; return SLJIT_SUCCESS;
} }
#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
#include "sljitNativeX86_32.c" #include "sljitNativeX86_32.c"
#else #else
#include "sljitNativeX86_64.c" #include "sljitNativeX86_64.c"
#endif #endif
static sljit_s32 emit_mov(struct sljit_compiler *compiler, static sljit_s32 emit_mov(struct sljit_compiler *compiler,
skipping to change at line 3126 skipping to change at line 3125
*inst++ = 0; *inst++ = 0;
*inst++ = 3; *inst++ = 3;
return put_label; return put_label;
} }
SLJIT_API_FUNC_ATTRIBUTE void sljit_set_jump_addr(sljit_uw addr, sljit_uw new_ta rget, sljit_sw executable_offset) SLJIT_API_FUNC_ATTRIBUTE void sljit_set_jump_addr(sljit_uw addr, sljit_uw new_ta rget, sljit_sw executable_offset)
{ {
SLJIT_UNUSED_ARG(executable_offset); SLJIT_UNUSED_ARG(executable_offset);
SLJIT_UPDATE_WX_FLAGS((void*)addr, (void*)(addr + sizeof(sljit_uw)), 0);
#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32) #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
sljit_unaligned_store_sw((void*)addr, new_target - (addr + 4) - (sljit_uw )executable_offset); sljit_unaligned_store_sw((void*)addr, new_target - (addr + 4) - (sljit_uw )executable_offset);
#else #else
sljit_unaligned_store_sw((void*)addr, (sljit_sw) new_target); sljit_unaligned_store_sw((void*)addr, (sljit_sw) new_target);
#endif #endif
SLJIT_UPDATE_WX_FLAGS((void*)addr, (void*)(addr + sizeof(sljit_uw)), 1);
} }
SLJIT_API_FUNC_ATTRIBUTE void sljit_set_const(sljit_uw addr, sljit_sw new_consta nt, sljit_sw executable_offset) SLJIT_API_FUNC_ATTRIBUTE void sljit_set_const(sljit_uw addr, sljit_sw new_consta nt, sljit_sw executable_offset)
{ {
SLJIT_UNUSED_ARG(executable_offset); SLJIT_UNUSED_ARG(executable_offset);
SLJIT_UPDATE_WX_FLAGS((void*)addr, (void*)(addr + sizeof(sljit_sw)), 0);
sljit_unaligned_store_sw((void*)addr, new_constant); sljit_unaligned_store_sw((void*)addr, new_constant);
SLJIT_UPDATE_WX_FLAGS((void*)addr, (void*)(addr + sizeof(sljit_sw)), 1);
} }
 End of changes. 23 change blocks. 
25 lines changed or deleted 33 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)