On Sun, 2 Jun 2024, Pali Rohár wrote:

WinMain() entry point provided by the application is called by mingw-w64
startup code, more precisely by function main() from crtexewin.c file.

mingw-w64 startup code in file crtexewin.c calls _ismbblead() function.
Function _ismbblead() is not available in some versions of crtdll.dll
and is completely missing in msvcrt10.dll library.

Version of crtdll.dll library stored in its PE resource directory is not
meaningful as two different libraries, one with _ismbblead symbol and one
without _ismbblead symbol has same version.

Seems that there are MBCS aware crtdll.dll versions with _ismbblead symbol
and versions which are not MBCS aware without _ismbblead symbol.

All checked msvcrt10.dll files do not have _ismbblead symbols, so
msvcrt10.dll is not MBCS awre.

For msvcrt10.dll import library provides simple dummy _ismbblead() function
which always returns false to satisfy mingw-w64 startup file crtexewin.c.

For crtdll.dll import library provides _ismbblead() wrapper function and
disable the real function in the def file to prevent symbol conflicts. The
wrapper function via GetProcAddress() checks if the real crtdll.dll
provides _ismbblead() function. If real function exists then it is called.
If not then wrapper function returns false like the msvcrt10.dll one.

This fixes linking WinMain() entry point with msvcrt10.dll.

 ld: /usr/local/lib/libmingw32.a(lib32_libmingw32_a-crtexewin.o): in function 
`main':
 mingw-w64/mingw-w64-crt/crt/crtexewin.c:43: undefined reference to `_ismbblead'
 collect2: error: ld returned 1 exit status

And fixes runtime error about missing _ismbblead symbol with some versions of 
crtdll.dll.

 Entry Point Not Found
 The procedure entry point _ismbblead could not be located in the
 dynamic link library CRTDLL.dll.
---
mingw-w64-crt/Makefile.am              |  2 ++
mingw-w64-crt/crt/crtdll_ismbblead.c   | 45 ++++++++++++++++++++++++++
mingw-w64-crt/crt/msvcrt10_ismbblead.c | 14 ++++++++
mingw-w64-crt/lib32/crtdll.def.in      |  2 +-
4 files changed, 62 insertions(+), 1 deletion(-)
create mode 100644 mingw-w64-crt/crt/crtdll_ismbblead.c
create mode 100644 mingw-w64-crt/crt/msvcrt10_ismbblead.c

Thanks, I pushed this one, together with patches 1-4 from the previous version of this patchset now.

// Martin

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

Reply via email to