This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [opensuse-mingw] RFH: Strange mingw behaviour
- From: Martin Koegler <martin dot koegler at chello dot at>
- To: Martin Koegler <martin dot koegler at chello dot at>
- Cc: binutils at sourceware dot org, opensuse-mingw at opensuse dot org
- Date: Wed, 9 Mar 2016 22:27:56 +0100
- Subject: Re: [opensuse-mingw] RFH: Strange mingw behaviour
- Authentication-results: sourceware.org; auth=none
- References: <20160307194610 dot GA11986 at mail dot zuhause>
On Mon, Mar 07, 2016 at 08:46:10PM +0100, Martin Koegler wrote:
> I'm trying to debug a mingw crash. My program failed to start with a acess violation on Windows.
It is the ld option --gc-sections:
d1.cpp:
====
extern const long testval[2] = {1, 2};
====
d2.cpp:
===
#include <stdio.h>
extern const long testval[];
int main()
{
printf("%p\n", testval);
printf("%d %d\n", testval[0], testval[1]);
return 0;
}
====
x86_64-w64-mingw32-g++ -o d1a.dll -shared d1.cpp -Wl,--out-implib -Wl,d1a.dll.a -Wl,--gc-sections
x86_64-w64-mingw32-g++ -o d1b.dll -shared d1.cpp -Wl,--out-implib -Wl,d1b.dll.a
x86_64-w64-mingw32-g++ -o d2a.exe d2.cpp d1a.dll.a => Crashes
x86_64-w64-mingw32-g++ -o d2A.exe d2.cpp d1a.dll => prints incorrect data
x86_64-w64-mingw32-g++ -o d2b.exe d2.cpp d1b.dll.a => OK
x86_64-w64-mingw32-g++ -o d2B.exe d2.cpp d1b.dll => OK
https://sourceware.org/bugzilla/show_bug.cgi?id=19480
https://sourceware.org/bugzilla/show_bug.cgi?id=19531
Regards,
Martin