Ticket #860 (closed task: fixed)
32-bit x86 assembler uses sib byte encoding for 32-bit displacements
|Reported by:||rme||Owned by:||rme|
r11754 is workaround for a bug in how the lisp assembler encodes memory operands that are just a displacement.
To elaborate on that commit message, there are two ways on 32-bit x86 to encode a memory operand that's just a displacement.
For example, take the instruction:
0x806e6db: mov %fs:0x84,%ecx
The lisp assembler encodes this as:
0x806e6db: 0x64 0x8b 0x0c 0x25 0x84 0x00 0x00 0x00
Note that the modrm byte of 0x0c (00 001 100) means that a sib byte follows.
This could also be encoded as this shorter sequence (and the Unix assembler does so):
0x806e6db: 0x64 0x8b 0x0d 0x84 0x00 0x00 0x00
The modrm byte of 0x0d (00 001 101) here means that the displacement follows.
The reason that the lisp assembler selects the longer encoding is because it targeted x86-64 first. On x86-64, the modrm byte in the shorter sequence is redefined to mean that the displacement is RIP-relative. Therefore, the longer sib byte encoding is used to specify just a displacement.
The lisp assembler needs to be persuaded to emit the shorter encoding for 32-bit x86. When it does, we can recompile and bump fasl versions, etc., and remove the workaround in pc_luser_xp().