x86 asm dllexport output for mingw targets

It seems that the DLL export directives for __cdecl and __stdcall functions are not correctly written in asm output.

For example, when declaring a function like this:

__declspec(dllexport) int __cdecl exportFunc1(int c);

ASM output is:

  .def _exportFunc1;
  .scl 2;
  .type 32;
  .endef
  .text
  .globl _exportFunc1
  .align 16, 0x90
_exportFunc1:
  movl 4(%esp), %eax
  ret

  .section .drectve,"r"
  .ascii " -export:_exportFunc1"

GNU assembler fails with the message that it can't find the symbol _exportFunc1. When removing the leading underscores
("-export:exportFunc1") GAS is happy. This is also how GCC for mingw behaves.
I can write a small patch for this but I just wanted to know if I am on the right path ...

Alen,

It seems that the DLL export directives for __cdecl and __stdcall
functions are not correctly written in asm output.

So, this is for all functions then, right? :slight_smile:

Well, __fastcall is working. That's because such functions have no preceding underscore but a '@'.

@exportFunc1@4

Just a note to my previous mail:
Actually, it's GNU ld which reports this error and not GAS.

regards,
Alen