|
It is worth pointing out that OpenBSD currently uses binutils 2.15, there have been several noteable amd64 changes since
such as: Changes from binutils 2.16.91.0.2: 2. Support x86-64 medium model. Changes from binutils 2.16.91.0.1: 4. Add x86-64 new relocations for medium model. When specifying -mcmodel=medium to gcc it will generate code with leal instructions that looks like that of pcc. I mistakenly used pcc in the last test not gcc, all leal instructions still use %r* registers with the different mcmodel it would seem.
This is a bug in the old gas used in OpenBSD, it do not accept constructs like "leal (%eax,%ebx),%ecx" which does not have anything to do with addresses but in fact is a 3-operand addition. pcc may emit it to avoid an extra movl instruction.
It must be fixed in OpenBSD, it's not a compiler problem. Newer gas supports this. |
leal (%eax,%ebx),%eax
leal (%eax,%ecx),%ebx
gcc:
leal (%rax,%rbx),%eax
leal (%rax,%rcx),%ebx
perhaps this wasn't noticed during development as NetBSD supports -m32 on amd64?