Summary: 64bit ASM can't have 32-bit stack operands
           Product: D
           Version: D1 & D2
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: druntime

--- Comment #0 from Iain Buclaw <> 2011-04-08 08:52:52 PDT ---
This is a question rolled into a report (it's affecting me, at least). This
excerpt (in core/thread.d for D2; in gc/gcx.d for D1 and D2) - the "push EAX"
instruction is not legal x86_64 asm code - according to the GNU 64bit
Assembler, which is strong enough an argument for me to follow - so is not
compilable with the GDC 64bit compiler (and maybe LDC too).

    push RAX ;
    push RBX ;
    push RCX ;
    push RDX ;
    push RSI ;
    push RDI ;
    push RBP ;
    push R8  ;
    push R9  ;
    push R10  ;
    push R11  ;
    push R12  ;
    push R13  ;
    push R14  ;
    push R15  ;
--> push EAX ;   // 16 byte align the stack    <-- This line causes the error
    mov sp[RBP],RSP     ;

So, what to do?

Well, first I think druntime should consider revising this code for a start.
And secondly, DMD should be hardened to catch and disallow this.

Some thoughts for how to change it:

In 32bit mode:
pusha (afaik) saves (e)ax, cx, dx, bx, sp, bp, si, di
popa restores (e)di, si, bp, bx, dx, cx, ax  (note, stack is not popped)

In GCC builtins:
unwind_init (what is currently being used in place of the above illegal code in
GDC) saves only the rbx, r12, r13, r14 and r15 registers.


Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to