Requesting D ABI clarifications

pragma pragma_member at pathlink.com
Thu May 11 06:59:25 PDT 2006


In article <e3u06e$2hg9$1 at digitaldaemon.com>, Gregor Richards says...
>
><preface>
>I'm writing a D compiler using C as an intermediary language et cetera 
>et cetera http://www.dsource.org/projects/tdc/
></preface>
>
>I have the lofty goal of DMD compatibility on those systems that DMD 
>supports, but unfortunately the ABI spec on the page isn't complete ... 
>I believe I have everything right (it seems to work) except for:
>
>A) Function calling semantics
>	- Some initial tests putting 'this' in %eax generated almost 100% 
>compatible code, but there were occasional strange, difficult to trace 
>errors - these could just be my mistakes, or I could be doing calling 
>semantics improperly.  Is that the only major difference from C calling 
>conventions, or is there something else specific I need to do?
>
>B) Exception handling
>	- For GNU/Linux, DMD's exception handling is for all intents and 
>purposes undocumed ... it mentions that it has a static location for 
>exception handling buffers, but that's about it.  I think I should be 
>able to get SEH working (I've found a few nice docs on it), but don't 
>have much of a base point for GNU/Linux ... all I know is a few symbols 
>(_deh_end et al).
>
>
>Could somebody (Walter?) either explain how these work in DMD or point 
>me to where these are explained?  I would really like to be compatible, 
>or at least as compatible as possible, with the reference ABI ... 
>hopefully this is doable from C (I'm willing to use GCC __attribute__'s 
>and inline assembly where necessary, this is how I got a parameter into 
>%eax).
>
>Thanks for any response.
>
>  - Gregor Richards

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.

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. :)

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.

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