Bug 4600 - MinGW32 DLL causes MSVC application initialization failure during runtime
Summary: MinGW32 DLL causes MSVC application initialization failure during runtime
Status: RESOLVED INVALID
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.17
: P2 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-06-07 17:16 UTC by Ioan
Modified: 2008-01-17 04:20 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
Test case mentioned in original post. (4.17 KB, application/x-zip-compressed)
2007-06-07 17:18 UTC, Ioan
Details
Compiled DLLs and executable test case. (258.96 KB, application/x-zip-compressed)
2007-06-08 12:44 UTC, Ioan
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ioan 2007-06-07 17:16:21 UTC
A simple mingw32 DLL with two source files (and headers). If the source file has
a name that doesn't alphabetically come before all other source files, the
resulting DLL causes a client MSVC application to crash during runtime. There
are no compiler or linker errors.

The attached archive contains the necessary files to test. It generates a
non-working example. To make it work, change the name of the "entrx.c" file to
something that would come after "entry.c", for example "entrz.c", and rebuild
the DLL.
Comment 1 Ioan 2007-06-07 17:18:03 UTC
Created attachment 1881 [details]
Test case mentioned in original post.
Comment 2 Ioan 2007-06-08 12:44:18 UTC
Created attachment 1882 [details]
Compiled DLLs and executable test case.
Comment 3 Ioan 2007-07-20 18:17:44 UTC
I've found the following workaround: Ensure the source file containing the entry
point function is the first one in the list when linking the final target.

For this particular test case, add the following line:
SRCS := src/entrx.c $(filter-out src/entrx.c,$(SRCS))

after this line (line 10):
SRCS = $(wildcard $(SRCDIR)/*.c)

The "entrx.c" file may now be named anything (as long as the makefile is
updated) because the new line ensures it comes first in the list of files (the
source file list is also used for the object files, but with a different extension).
Comment 4 Alan Modra 2008-01-17 04:20:39 UTC
Not a bug.