symbol names are not created with stdcall syntax: MINGW, (GCC) 4.3.0 20061021

Tobias Burnus burnus@net-b.de
Fri Mar 9 15:28:00 GMT 2007


Hi,

Brian Dessent wrote:
> In short, the feature you want does not exist.  And to make it exist
> requires co-operation from the compiler, not the linker.  There are two
> aspects here: one, the actual calling convention (whether caller or
> callee pops arguments, and in what order they are pushed)
I think this is done by -mrtd:

"Use a different function-calling convention, in which functions that take a
fixed number of arguments return with the "ret" num instruction, which pops
their arguments while returning."


> and function name decoration (whether @nn is appended to the name of the function or
> not.) The linker can only help you with the latter, by optionally
> linking functions of one name mangling to the other.  But in order for
> this to be meaningfully correct, both functions must have been
> originally compiled with the same calling convention (just with
> different name manglings.)  And the linker has no control over that.
>   
The question remains how to do this. "ld" does not seem to offer this
for the Linker.

 * * *

In GNAT's Users Guide I found that ADA offers a pragma to do this:*
*   pragma Import (Stdcall, Get_Val);
http://gcc.gnu.org/onlinedocs/gnat_ugn_unw/Stdcall-Calling-Convention.html

This seems to use the "right" calling convention and to create @nn (nn =
overall byte-size of parameters passed).

How is this done in C?
For C I found:
http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Function-Attributes.html
And indeed, using "gcc -m32 -c" works with:
__attribute__ ((stdcall)) void foo(void)  { /* ... */ }

However, this seems to do only the same thing as -mrtd, i.e. the calling
convention, and does not append the @nn. And a bit of googling only
found methods to get rid of the @nn (-> ld, dlltools, ...). You might be
able to get something working with .def files? Or what do Mingw's
__declspec(dllexport) and __declspec(dllimport) ?

How do other Fortran compilers handle this?

Tobias,
who is a Linux user

PS: See also PR 31073.



More information about the Fortran mailing list