Commit 7530e70
authored
[X86] Ignore REX prefixes not immediately before opcode (llvm#117299)
The Intel X86 Architecture Manual says the following:
> A REX prefix is ignored, as are its individual bits, when it is not
needed
> for an instruction or when it does not immediately precede the opcode
byte or
> the escape opcode byte (0FH) of an instruction for which it is needed.
This
> has the implication that only one REX prefix, properly located, can
affect an
> instruction.
We currently do not handle these cases in the disassembler, leading to
incorrect disassembly. This patch rectifies the situation by treating
REX prefixes as standard prefixes rather than only expecting them before
the Opcode.
The motivating test case added as a test was fuzzer generated.1 parent 71f14ff commit 7530e70
File tree
2 files changed
+14
-5
lines changed- llvm
- lib/Target/X86/Disassembler
- test/MC/Disassembler/X86
2 files changed
+14
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
329 | 329 | | |
330 | 330 | | |
331 | 331 | | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
332 | 340 | | |
333 | 341 | | |
334 | 342 | | |
| |||
506 | 514 | | |
507 | 515 | | |
508 | 516 | | |
509 | | - | |
510 | | - | |
511 | | - | |
512 | | - | |
513 | | - | |
514 | 517 | | |
515 | 518 | | |
516 | 519 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
770 | 770 | | |
771 | 771 | | |
772 | 772 | | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
0 commit comments