i386-asm.c: Do bit-check for OP_SEG in asm_opcode

Fix a bug with "call *%%gs:16", which sets the two flags OP_INDIR and
OP_SEG in pop->type.
This commit is contained in:
Stefan 2025-09-21 10:47:33 +02:00
parent de8c19e1da
commit 9dc59f9c23

View File

@ -722,7 +722,7 @@ ST_FUNC void asm_opcode(TCCState *s1, int opcode)
} }
parse_operand(s1, pop); parse_operand(s1, pop);
if (tok == ':') { if (tok == ':') {
if (pop->type != OP_SEG || seg_prefix) if (!(pop->type & OP_SEG) || seg_prefix)
tcc_error("incorrect prefix"); tcc_error("incorrect prefix");
seg_prefix = segment_prefixes[pop->reg]; seg_prefix = segment_prefixes[pop->reg];
next(); next();
@ -852,7 +852,7 @@ again:
if (opcode >= TOK_ASM_first && opcode <= TOK_ASM_last) { if (opcode >= TOK_ASM_first && opcode <= TOK_ASM_last) {
int b; int b;
b = op0_codes[opcode - TOK_ASM_first]; b = op0_codes[opcode - TOK_ASM_first];
if (b & 0xff00) if (b & 0xff00)
g(b >> 8); g(b >> 8);
g(b); g(b);
return; return;