History

Add endbr32 for i386

herman ten brugge committed 1 year ago

Commit 7657d871 parent 854d6c52 files · +9 −3Browse files

Unified · Split

2 files
  1. i386-asm.c +5 −2
  2. i386-asm.h +4 −1
i386-asm.c+5−2
@@ -1002,21 +1002,24 @@ again: · 1001 unmodified lines
10021002 modrm_index = -1;
10031003 modreg_index = -1;
10041004 if (pa->instr_type & OPC_MODRM) {
1005−#ifdef TCC_TARGET_X86_64
10061005 if (!nb_ops) {
10071006 /* A modrm opcode without operands is a special case (e.g. mfence).
10081007 It has a group and acts as if there's an register operand 0 */
10091008 i = 0;
10101009 ops[i].type = OP_REG;
1010+#ifdef TCC_TARGET_X86_64
10111011 if (pa->sym == TOK_ASM_endbr64)
10121012 ops[i].reg = 2; // dx
10131013 else if (pa->sym >= TOK_ASM_lfence && pa->sym <= TOK_ASM_sfence)
10141014 ops[i].reg = 0; // ax
1015+#else
1016+ if (pa->sym == TOK_ASM_endbr32)
1017+ ops[i].reg = 3; // bx
1018+#endif
10151019 else
10161020 tcc_error("bad MODR/M opcode without operands");
10171021 goto modrm_found;
10181022 }
1019−#endif
10201023 /* first look for an ea operand */
10211024 for(i = 0;i < nb_ops; i++) {
10221025 if (op_type[i] & OP_EA)
i386-asm.h+4−1
@@ -37,7 +37,10 @@ · 36 unmodified lines
3737 DEF_ASM_OP0(pause, 0xf390)
3838 DEF_ASM_OP0(xlat, 0xd7)
3939
40− /* strings */
40+ /* Control-Flow Enforcement */
41+ DEF_ASM_OP0L(endbr32, 0xf30f1e, 7, OPC_MODRM)
42+
43+ /* strings */
4144 ALT(DEF_ASM_OP0L(cmpsb, 0xa6, 0, OPC_BWLX))
4245 ALT(DEF_ASM_OP0L(scmpb, 0xa6, 0, OPC_BWLX))
4346

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t