http://sourceware.org/bugzilla/show_bug.cgi?id=14339
Bug #: 14339
Summary: MinGW ld omits stubs when linking delay import library
and using __declspec(dllimport)
Product: binutils
Version: 2.22
Status: NEW
Severity: normal
Priority: P2
Component: ld
AssignedTo: [email protected]
ReportedBy: [email protected]
Classification: Unclassified
Created attachment 6520
--> http://sourceware.org/bugzilla/attachment.cgi?id=6520
Test case source
Delay import libraries contain stubs in the form of:
_WSAStartup@8:
00000000: FF 25 00 00 00 00 jmp dword ptr [.idata$5]
00000006: B8 00 00 00 00 mov eax,offset .idata$5
0000000B: E9 00 00 00 00 jmp ___tailMerge_libws2_32_delayed_a
These are then referenced in the corresponding .idata section à la:
RAW DATA #5
00000000: 06 00 00 00 ....
RELOCATIONS #5
Symbol Symbol
Offset Type Applied To Index Name
-------- ---------------- ----------------- -------- ------
00000000 DIR32 00000006 0 .text
When using __declspec(dllimport), only the symbol in .idata$5
(__imp__WSAStartup@8) is referenced, not _WSAStartup@8 in the .text section.
This apparently causes the linker to omit the stub, and turn the corresponding
relocation into a no-op (i.e. the application will call the address 6).
--whole-archive has no effect on this, the stubs are still omitted.
Linking the individual object files as extracted from the library DOES produce
correct output, though.
Adding '-u _WSAStartup@8' to the command line also seems to work.
I've made a small test case including an analysis of the generated code.
The source for this test case is attached. It can also (including compiled
binaries and disassembly) be found at:
http://thfabba.ath.cx/~thfabba/pub/delaylib/
I've tested this with ld version 2.20.51.20091222 (ReactOS Build Environment),
as well as MinGW's 2.22 and MinGW-w64's 2.22.51.20111217.
Possibly, but not necessarily related to bug 12614.
--
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
_______________________________________________
bug-binutils mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-binutils