Commit 7d67b97f authored by Wim Taymans's avatar Wim Taymans Committed by Tim-Philipp Müller

x86: add endbr32 and endbr64 instructions

Issue endbr instructions at the start of generated functions to
make IBT (indirect branch tracking) work.

Resolves #17
parent 5d0d6ce3
......@@ -452,6 +452,9 @@ orc_x86_emit_prologue (OrcCompiler *compiler)
orc_compiler_append_code(compiler,"%s:\n", compiler->program->name);
if (compiler->is_64bit) {
int i;
orc_x86_emit_cpuinsn_none (compiler, ORC_X86_endbr64);
for(i=0;i<16;i++){
if (compiler->used_regs[ORC_GP_REG_BASE+i] &&
compiler->save_regs[ORC_GP_REG_BASE+i]) {
......@@ -459,6 +462,7 @@ orc_x86_emit_prologue (OrcCompiler *compiler)
}
}
} else {
orc_x86_emit_cpuinsn_none (compiler, ORC_X86_endbr32);
orc_x86_emit_push (compiler, 4, X86_EBP);
if (compiler->use_frame_pointer) {
orc_x86_emit_mov_reg_reg (compiler, 4, X86_ESP, X86_EBP);
......
......@@ -254,6 +254,8 @@ static const OrcSysOpcode orc_x86_opcodes[] = {
{ "pshufw", ORC_X86_INSN_TYPE_IMM8_MMXM_MMX, 0, 0x00, 0x0f70 },
{ "movq", ORC_X86_INSN_TYPE_MMXM_MMX, 0, 0x00, 0x0f6f },
{ "movq", ORC_X86_INSN_TYPE_MMXM_MMX_REV, 0, 0x00, 0x0f7f },
{ "endbr32", ORC_X86_INSN_TYPE_NONE, 0, 0xf3, 0x0f1efb },
{ "endbr64", ORC_X86_INSN_TYPE_NONE, 0, 0xf3, 0x0f1efa },
};
static void
......
......@@ -278,6 +278,8 @@ typedef enum {
ORC_X86_pshufw,
ORC_X86_movq_mmx_load,
ORC_X86_movq_mmx_store,
ORC_X86_endbr32,
ORC_X86_endbr64,
} OrcX86Opcode;
enum {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment