https://sourceware.org/bugzilla/show_bug.cgi?id=20979
Bug ID: 20979 Summary: DLL relocation totally broken Product: binutils Version: 2.25 Status: UNCONFIRMED Severity: critical Priority: P2 Component: binutils Assignee: unassigned at sourceware dot org Reporter: lindasc at qq dot com Target Milestone: --- Created attachment 9707 --> https://sourceware.org/bugzilla/attachment.cgi?id=9707&action=edit minimal case for the DLL relocation bug OS: Win7 SP1 Toolchain: Mingw-w64 i686-6.2.0-release-win32-dwarf-rt_v5-rev1 Binutils: 2.25.1 I don't know whether it's a GCC bug or a binutils bug, but I think it's not a mingw bug. I can't submit bug to GCC bugzilla because it is rejecting new account creation. Consider a dll whose base address is overlapped with an existing module, so that the operating system must relocate it, or for another word, rebase it, to work. Relocation is the fundamental part of the security feature ASLR and is enabled by default since Windows Vista. When ASLR is enabled, all executables are relocated. BUT, After relocation, the compiled DLL fails to load at all. That's to say, the compiled DLL is broken. Not only x86-dw2 builds produces the broken DLL, but x86-sjlj, x64-sjlj, x64-seh, all gcc 6.2 builds with binutils 2.25.1 have the same problem. OH MY GOD. I believe previous builds also have the same problem. Minical case: ===================== testexe.c ===================== #include <stdio.h> __declspec(dllimport) int a(); int main() { a(); printf("hello world\n"); return 0; } ===================== testdll.c ===================== __declspec(dllexport) int a() {return 0;} ===================== test.def ===================== EXPORTS a ===================== makefile ===================== all: test.dll test.exe clean: rm test.exe test.dll libtest.a test.exe: testexe.c gcc -o $@ $^ libtest.a -Wl,--image-base,0x400000 test.dll: testdll.c dllwrap -o $@ $^ --def test.def --implib libtest.a -Wl,--image-base,0x400000 ===================== Case end. Also see the attachment. In this case, test.exe refuses to work with error 0xC0000005 because test.dll fails to load. I don't know what's going wrong, GCC or binutils? Nothing is wrong when using Microsoft Visual C++. It's really annoying to see GCC compiled programs showing 0xC0000005 frequently and randomly. -- You are receiving this mail because: You are on the CC list for the bug. _______________________________________________ bug-binutils mailing list bug-binutils@gnu.org https://lists.gnu.org/mailman/listinfo/bug-binutils