Symbols @_calloc_crt@8, @_malloc_crt@4 and @_realloc_crt@8 are exported
from msvcr80 DLL libraries with their @suffix decoration. This is not
usual.

Those decorated symbols refers to fastcall function calling convention.

When generating import library, @suffix must not be trimmed (which is done
by default by mingw-w64 build procedure due to usage of dlltool --kill-at
switch), otherwise linking would fail.

Note that suffix @size for fastcall functions does not refer to size of the
stack used for arguments, but rather to size of all arguments (passed in
registers + stack). All these functions take arguments only in registers.

So fix symbols in import libraries by rename operator '==' like it is
already used for stdcall decorated symbols. dlltool --kill-at switch does
not trim right side of the rename operator '=='.

To make declarations of these functions more readable, introduce a new
FASTCALL_DECORATED_EXPORT() macro for it.
---

Tested with following code:

  void * __fastcall _calloc_crt(int a, int b);
  int printf(const char *, ...);
  int main() {
    char *buf = _calloc_crt(5, 1);
    printf("%u %u %u %u %u\n", buf[0], buf[1], buf[2], buf[3], buf[4]);
    buf[0] = 'A';
    printf("%s\n", buf);
    return 0;
  }

With proper manifest file, application properly prints zeros and A.
And objdump -p for application prints:

  DLL Name: MSVCR80D.dll
  vma:  Hint/Ord Member-Name Bound-To
  ...
  635c     1710  @_calloc_crt@8

---
 mingw-w64-crt/def-include/func.def.in | 1 +
 mingw-w64-crt/lib32/msvcr80.def.in    | 6 +++---
 mingw-w64-crt/lib32/msvcr80d.def.in   | 6 +++---
 3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/mingw-w64-crt/def-include/func.def.in 
b/mingw-w64-crt/def-include/func.def.in
index 0d1ea7770d04..fdda790a9b90 100644
--- a/mingw-w64-crt/def-include/func.def.in
+++ b/mingw-w64-crt/def-include/func.def.in
@@ -63,6 +63,7 @@
 
 #if defined(DEF_I386)
 #define STDCALL_DECORATED_EXPORT(symbol) symbol == _ ## symbol
+#define FASTCALL_DECORATED_EXPORT(symbol) symbol == symbol
 #endif
 
 #endif // FUNC_DEF_IN
diff --git a/mingw-w64-crt/lib32/msvcr80.def.in 
b/mingw-w64-crt/lib32/msvcr80.def.in
index 9d4e30ebe483..0e6842561612 100644
--- a/mingw-w64-crt/lib32/msvcr80.def.in
+++ b/mingw-w64-crt/lib32/msvcr80.def.in
@@ -143,9 +143,9 @@ EXPORTS
 
 ; Symbols from the original Microsoft Visual C++ 2005 version of msvcr80.dll
 __uncaught_exception
-@_calloc_crt@8
-@_malloc_crt@4
-@_realloc_crt@8
+FASTCALL_DECORATED_EXPORT(@_calloc_crt@8)
+FASTCALL_DECORATED_EXPORT(@_malloc_crt@4)
+FASTCALL_DECORATED_EXPORT(@_realloc_crt@8)
 $I10_OUTPUT
 _CIacos
 _CIasin
diff --git a/mingw-w64-crt/lib32/msvcr80d.def.in 
b/mingw-w64-crt/lib32/msvcr80d.def.in
index 6bcbf03e9562..ed7d3e8faf1c 100644
--- a/mingw-w64-crt/lib32/msvcr80d.def.in
+++ b/mingw-w64-crt/lib32/msvcr80d.def.in
@@ -160,9 +160,9 @@ EXPORTS
 
 ; Symbols from the original Microsoft Visual C++ 2005 version of msvcr80d.dll
 __uncaught_exception
-@_calloc_crt@8
-@_malloc_crt@4
-@_realloc_crt@8
+FASTCALL_DECORATED_EXPORT(@_calloc_crt@8)
+FASTCALL_DECORATED_EXPORT(@_malloc_crt@4)
+FASTCALL_DECORATED_EXPORT(@_realloc_crt@8)
 $I10_OUTPUT
 _CIacos
 _CIasin
-- 
2.20.1



_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to