Requesting D ABI clarifications

Walter Bright newshound at digitalmars.com
Sat May 13 00:54:04 PDT 2006


pragma wrote:
> Well, I do know that there are some variations in how D is supported across
> Windows and Linux.  I say this because Walter himself seems rather dubious that
> aiming for cross-platform runtime linking (ala DDL) is "folly" since there are
> subtle differences.  While I'd like to maintain that this only applies under
> certain circumstances, I honestly don't know what the baseline for binary
> compatiblity really is.

The baseline is being ABI compatible with the host C compiler on the 
target platform.

> A) I think you're on the right track with using eax. It was mentioned some time
> ago that the *first* parameter of any function/method signature is placed into
> eax rather than on the stack.  I believe that eax is also used for return values
> - no suprises there. :)

Actually, the *last* parameter goes into EAX, if it fits.

> B) If memory serves, I think Walter went on the record as saying that the
> exception handling mechanisms are *different* between win32 and linux (the
> latter having to do with GDC/GDB compatibility I guess).  I hope I'm wrong about
> that, as this just seems to make life harder than necessary.  IMNSHO, using
> separate SEH mechanisms kind of ruins the idea of a true ABI.

They are different. Win32 uses the NT SEH, which has no counterpart on 
linux. For linux, I would use g++'s .eh_frame method, but it is (as far 
as I can tell) completely undocumented. So I gave up on that, and simply 
used what I'd invented for C++ exceptions on 32 bit DOSX.

The code to make it work is in phobos/internal/deh2.d.

> Other things, I've learned through a good amount of hacking. But they really
> center around how OMF objects are generated - I'm still learning the ELF side of
> things, but so far there aren't many suprises.
> 
> Personally, I'd like to know more, and to see more of the ABI fleshed out so I
> can make some sound technical decisions in my project.  Like you, I'd rather not
> just poke around in the dark and make reccomendations and decisions based on
> what just happens to work.
> 
> - EricAnderton at yahoo



More information about the Digitalmars-d mailing list