[PATCH] ld: fix 32-bit mingw DLL symbol export bug

Oleg Tolmatcev oleg.tolmatcev@gmail.com
Tue Dec 26 14:24:56 GMT 2023


Hello,

I think there's a bug in ld on 32-bit Windows.Here is a tiny project
for reproducing the problem. https://github.com/oltolm/ld-mingw32-bug

A 32-bit DLL exports two stdcall functions "myfunc" and "myfunc64".
The functions would normally get exported as "myfunc@0" and
"myfunc64@0". The "DEF" file exports them as "myfunc" and "myfunc64"
without the decorations. When you run the executable it shows an error
message saying that it can not find "myfunc64". I think it happens
because the sorting in ld is wrong.

I think it should use the exported names "myfunc" and "myfunc64", but
instead it uses the decorated names "myfunc@0" or "myfunc65@0". The
ordering of functions in the DLL is different depending on which names
you use.

My patch changes ld to use undecorated exported names for sorting and
it seems to fix the problem. When I execute ctest in my project, it
runs successfully.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-ld-fix-32-bit-mingw-DLL-symbol-export-bug.patch
Type: application/octet-stream
Size: 948 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20231226/69b9b802/attachment.obj>


More information about the Binutils mailing list