Thread overview
[Issue 14872] [2.068.2] Label address in asm [x86-64]
[Issue 14872] [2.068.0-rc1] Label address in asm [x86-64]
Sep 29, 2015
Daniel
Sep 29, 2015
Daniel
Jul 21, 2017
Vladimir Panteleev
Dec 12, 2019
Basile-z
Mar 21, 2020
Basile-z
Aug 27, 2020
Dlang Bot
Aug 27, 2020
Dlang Bot
September 29, 2015
https://issues.dlang.org/show_bug.cgi?id=14872

--- Comment #1 from Daniel <wyrlon@gmx.net> ---
I tested that it works with ldc2 and saw some interesting things when disassembling at asm.dlang.org

dmd -m32
lea    %cs:0x28,%eax
mov    %eax,-0x8(%ebp)
lea    %cs:0x30,%eax
mov    %eax,-0x4(%ebp)

dmd -m64
cs
mov    %rax,%rax
mov    %rax,-0x10(%rbp)
cs
mov    %rax,%rax
mov    %rax,-0x8(%rbp)

ldc2 -m64
leaq    .L_Dmain_lbl1, %rax
movq    %rax, -72(%rbp)
leaq    .L_Dmain_lbl2, %rax
movq    %rax, -80(%rbp)

--
September 29, 2015
https://issues.dlang.org/show_bug.cgi?id=14872

Daniel <wyrlon@gmx.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[2.068.0-rc1] Label address |[2.068.2] Label address in
                   |in asm [x86-64]             |asm [x86-64]

--
July 21, 2017
https://issues.dlang.org/show_bug.cgi?id=14872

Vladimir Panteleev <dlang-bugzilla@thecybershadow.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
                 OS|Windows                     |All

--- Comment #2 from Vladimir Panteleev <dlang-bugzilla@thecybershadow.net> ---
(In reply to Daniel from comment #0)
> 32bit x86 asm works fine, but I can't get 64bit working.

I think that has something to do with Intel x64 being position-independent, meaning that "lea RAX, lbl1" is not going to do what you want. It looks like in case of DMD, it's generating nonsense code (mov eax, eax), but it could still use the offset relative to some base. In any case, it certainly won't be the actual in-address memory of the code at that label (so that you can "jmp" to it).

So, your example is a bit nonsensical, but DMD should still not be emitting garbage code, and either generate an error or use some other kind of offset (so that it's at least possible to use the offset in calculations to produce something useful).

--
December 12, 2019
https://issues.dlang.org/show_bug.cgi?id=14872

Basile-z <b2.temp@gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |iasm
                 CC|                            |b2.temp@gmx.com

--
March 21, 2020
https://issues.dlang.org/show_bug.cgi?id=14872

Basile-z <b2.temp@gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|b2.temp@gmx.com             |

--
August 27, 2020
https://issues.dlang.org/show_bug.cgi?id=14872

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #3 from Dlang Bot <dlang-bot@dlang.rocks> ---
@WalterBright created dlang/dmd pull request #11631 "fix Issue 14872 - [2.068.2] Label address in asm [x86-64]" fixing this issue:

- fix Issue 14872 - [2.068.2] Label address in asm [x86-64]

https://github.com/dlang/dmd/pull/11631

--
August 27, 2020
https://issues.dlang.org/show_bug.cgi?id=14872

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #4 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/dmd pull request #11631 "fix Issue 14872 - [2.068.2] Label address in asm [x86-64]" was merged into master:

- b8a8d6f183342bb5bd9944595218661efcb22b08 by Walter Bright:
  fix Issue 14872 - [2.068.2] Label address in asm [x86-64]

https://github.com/dlang/dmd/pull/11631

--