diff --git a/i386-asm.c b/i386-asm.c index 470b20e7..b0f10978 100644 --- a/i386-asm.c +++ b/i386-asm.c @@ -1002,21 +1002,24 @@ again: modrm_index = -1; modreg_index = -1; if (pa->instr_type & OPC_MODRM) { -#ifdef TCC_TARGET_X86_64 if (!nb_ops) { /* A modrm opcode without operands is a special case (e.g. mfence). It has a group and acts as if there's an register operand 0 */ i = 0; ops[i].type = OP_REG; +#ifdef TCC_TARGET_X86_64 if (pa->sym == TOK_ASM_endbr64) ops[i].reg = 2; // dx else if (pa->sym >= TOK_ASM_lfence && pa->sym <= TOK_ASM_sfence) ops[i].reg = 0; // ax +#else + if (pa->sym == TOK_ASM_endbr32) + ops[i].reg = 3; // bx +#endif else tcc_error("bad MODR/M opcode without operands"); goto modrm_found; } -#endif /* first look for an ea operand */ for(i = 0;i < nb_ops; i++) { if (op_type[i] & OP_EA) diff --git a/i386-asm.h b/i386-asm.h index 0f99b286..107fd3d0 100644 --- a/i386-asm.h +++ b/i386-asm.h @@ -37,7 +37,10 @@ DEF_ASM_OP0(pause, 0xf390) DEF_ASM_OP0(xlat, 0xd7) - /* strings */ + /* Control-Flow Enforcement */ + DEF_ASM_OP0L(endbr32, 0xf30f1e, 7, OPC_MODRM) + + /* strings */ ALT(DEF_ASM_OP0L(cmpsb, 0xa6, 0, OPC_BWLX)) ALT(DEF_ASM_OP0L(scmpb, 0xa6, 0, OPC_BWLX))