Hello! I'm experiencing an issue when building a shared library / DLL for the x86 architecture using gcc. All public functions use the __stdcall calling convention and are exported using a .def file so to have undecorated names in the resulting DLL. That is helpful for users that want to use GetProcAddress(). However gcc generates an import lib with undecorated names also in the symbols table. That causes linking errors, because the compiler can only know about decorated symbols. The error doesn't happen when building with other compilers like clang or msvc. The resulting import libraries always have decorated symbols. See also the relevant discussion at https://sourceforge.net/p/mingw-w64/mailman/message/37839853/ Thank you very much! Luca Bacci
As linked in the discussion, there's a sample repo at https://github.com/lb90/my-shared-lib Another report of the issue is at https://github.com/KhronosGroup/OpenCL-ICD-Loader/issues/191 Thanks, Luca
Created attachment 14877 [details] draft patch
Created attachment 14878 [details] draft patch rev2
From binutils/MAINTAINERS: ``` The home page for binutils is: http://www.gnu.org/software/binutils/binutils.html and patches should be sent to: binutils@sourceware.org ```
Ah, true! I have now sent an email: https://sourceware.org/pipermail/binutils/2023-May/127440.html
The master branch has been updated by Nick Clifton <nickc@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=80d4e113d7b9af8a5a36e5ea4399bca86050784f commit 80d4e113d7b9af8a5a36e5ea4399bca86050784f Author: Luca Bacci <luca.bacci@outlook.com> Date: Wed May 17 13:38:14 2023 +0100 Decorated symbols in import libs (BUG 30421) PR 30421 * cofflink.c (_decoration_hash_newfunc): New function. (_bfd_coff_link_hash_table_init): Call it. * libcoff-in.h (struct coff_link_hash_table): Add decoration_hash field. (struct decoration_hash_entry): Declare. (_decoration_hash_newfunc): Prototype. * libcoff.h: Regenerate. * emultempl/pe.em (set_decoration): New function. (pe_fixup_stdcalls): Call the new function. * emultempl/pep.em (set_decoration): New function. (pep_fixup_stdcalls): Call the new function. * pe-dll.c (make_one): Check for decoated symbols.
Fixed with commit 80d4e113