Issue Details (XML | Word | Printable)

Key: PCC-82
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Anders Magnusson
Reporter: Daniel Dickman
Votes: 1
Watchers: 0

If you were logged in you would be able to see more operations.

invalid assembly on amd64

Created: 19/Aug/09 09:31 PM   Updated: 03/Jun/10 09:57 PM
Component/s: None
Affects Version/s: None
Fix Version/s: None

[/usr/src/bin/cp] uname -msrvp
OpenBSD 4.6 GENERIC.MP#130 amd64 Intel(R) Core(TM)2 Duo CPU T7100 @ 1.80GHz

 Description  « Hide
Compiling with -O2 on OpenBSD/amd64 produces the following error for some code

[/usr/src/bin/cp] pcc -O2 -c cp.c
/tmp/ctm.sE01ll: Assembler messages:
/tmp/ctm.sE01ll:488: Error: `(%eax,%r14d)' is not a valid 64 bit base/index expression

Leaving out the -O2 seems to work
[/usr/src/bin/cp] pcc -c cp.c

 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Jonathan Gray added a comment - 14/Sep/09 05:25 PM

        leal (%eax,%ebx),%eax
        leal (%eax,%ecx),%ebx


        leal (%rax,%rbx),%eax
        leal (%rax,%rcx),%ebx

perhaps this wasn't noticed during development as NetBSD supports -m32 on amd64?

Jonathan Gray added a comment - 14/Sep/09 06:25 PM
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. Support x86-64 medium model.
Changes from binutils
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.

Jonathan Gray added a comment - 14/Sep/09 06:33 PM
I mistakenly used pcc in the last test not gcc, all leal instructions still use %r* registers with the different mcmodel it would seem.

Anders Magnusson made changes - 03/Jun/10 09:53 PM
Field Original Value New Value
Assignee Anders Magnusson [ ragge ]
Anders Magnusson added a comment - 03/Jun/10 09:57 PM
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.

Anders Magnusson made changes - 03/Jun/10 09:57 PM
Status Open [ 1 ] Closed [ 6 ]
Resolution Fixed [ 1 ]