diff options
| author | Michael Matz <matz@suse.de> | 2016-05-16 05:10:21 +0200 |
|---|---|---|
| committer | Michael Matz <matz@suse.de> | 2016-05-16 05:10:21 +0200 |
| commit | f2a4cb0a0edc95ae74816275e82b4ade71c6f37a (patch) | |
| tree | eaae6cc045f5d4271dd9778cbdb0b222b2c1470e /i386-asm.c | |
| parent | 0f36f60faa05da7e250a4b4eebd4b534e8a2b537 (diff) | |
| download | tinycc-f2a4cb0a0edc95ae74816275e82b4ade71c6f37a.tar.gz tinycc-f2a4cb0a0edc95ae74816275e82b4ade71c6f37a.tar.bz2 | |
x86-asm: Reject some invalid arith imm8 instruction
There were two errors in the arithmetic imm8 instruction. They accept
only REGW, and in case the user write a xxxb opcode that variant
needs to be rejected as well (it's not automatically rejected by REGW
in case the destination is memory).
Diffstat (limited to 'i386-asm.c')
| -rw-r--r-- | i386-asm.c | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -552,7 +552,14 @@ ST_FUNC void asm_opcode(TCCState *s1, int opcode) continue; s = (opcode - pa->sym) % NBWLX; if ((pa->instr_type & OPC_BWLX) == OPC_WLX) + { + /* We need to reject the xxxb opcodes that we accepted above. + Note that pa->sym for WLX opcodes is the 'w' token, + to get the 'b' token subtract one. */ + if (((opcode - pa->sym + 1) % NBWLX) == 0) + continue; s++; + } } else if (pa->instr_type & OPC_SHIFT) { if (!(opcode >= pa->sym && opcode < pa->sym + 7*NBWLX)) continue; |
