在 2023-05-05 01:53, Jeremy Drake via Mingw-w64-public 写道:
You might also be interested in the linker options --add-stdcall-alias/--enable-stdcall-fixup, but I think those are just for symbols exported by annotating with dllexport (or --export-all-symbols), not for those explicitly exported from a def file.
I would like to say this is bad suggestion. `--add-stdcall-alias` will create two aliases for every function; the undecorated one is normally unusable.
The 'proper' workaround for this (probable) bug is:
# First, create a DEF containing correctly decorated names. The DLL
# is unwanted and can be /dev/null.
gcc test.c -shared -O2 -o test.dll -Wl,--output-def,test.def
# Second, create a DLL containing names with the stdcall suffixes
# removed, which makes it suitable for `GetProcAddress()`.
gcc test.c -shared -O2 -o test.dll -Wl,--kill-at
# Finally, create an import library from the DEF, which redirects
# decorated names to stripped ones.
dlltool -d test.def -l libtest.dll.a
# The DEF file is of no interest and can be removed.
rm test.def
The result looks like this:
$ objdump -p test.dll | grep my_func
[ 0] my_func
$ nm --defined-only libtest.dll.a | grep xadd
00000000 I __imp__my_func@8
00000000 T _my_func@8
--
Best regards,
LIU Hao
OpenPGP_signature
Description: OpenPGP digital signature
_______________________________________________ Mingw-w64-public mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
