Add endbr32 for i386

This commit is contained in:
herman ten brugge
2025-07-14 08:27:14 +02:00
parent 854d6c5ab4
commit 7657d871c1
2 changed files with 9 additions and 3 deletions

View File

@@ -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)

View File

@@ -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))