This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [opensuse-mingw] RFH: Strange mingw behaviour


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]