From 9dc59f9c23a8e50d0d688a74a1cdc7fb352fba0c Mon Sep 17 00:00:00 2001 From: Stefan Date: Sun, 21 Sep 2025 10:47:33 +0200 Subject: [PATCH] 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. --- i386-asm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/i386-asm.c b/i386-asm.c index 68298737..e3889dc9 100644 --- a/i386-asm.c +++ b/i386-asm.c @@ -722,7 +722,7 @@ ST_FUNC void asm_opcode(TCCState *s1, int opcode) } parse_operand(s1, pop); if (tok == ':') { - if (pop->type != OP_SEG || seg_prefix) + if (!(pop->type & OP_SEG) || seg_prefix) tcc_error("incorrect prefix"); seg_prefix = segment_prefixes[pop->reg]; next(); @@ -852,7 +852,7 @@ again: if (opcode >= TOK_ASM_first && opcode <= TOK_ASM_last) { int b; b = op0_codes[opcode - TOK_ASM_first]; - if (b & 0xff00) + if (b & 0xff00) g(b >> 8); g(b); return;