MINGW-packages: any ld.exe from binutils > v2.30 is broken

Hello, I found that any ld.exe from binutils > v2.30 is broken and returns ld returned 5 exit status error code. So I have tried to download mingw-w64-i686-binutils-2.30-6-any.pkg.tar.xz from msys2 repo http://repo.msys2.org and replaced the installed ld.exe with the downloaded one, this times it compiled and linked without problems.

My code is very big to share it so you can reproduce it yourself. My code requires at least wxWidgets v3.1.3 to build.

What can I do make you believe that any version > v2.30 is really broken!? Because it is working without problems for small projects and makes you believe it is working properly.

Thank you in advance.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 1
  • Comments: 21 (16 by maintainers)

Commits related to this issue

Most upvoted comments

Interesting. Might want to report that to binutils bugzilla. I’m going to try to get a symbolicated backtrace at least, maybe I can find a simple patch for it.

There was just a discussion on gitter which revealed that upstream cmake attempts to create executables with -Wl,–out-implib and that that is failing now with --enable-reloc-section enabled, which is now enabled by default, and was enabled with -Wl,–dynamicbase as of 2.34 IIRC. And -Wl,–export-all-symbols does work around it.

So it sounds like attempting to create an import library while linking an executable with a relocation section but no exported symbols fails with exit code 5.

@droidmonkey I experienced the same linker error for some but not all keepassx unit tests. It seems that ASLR (-Wl,--dynamicbase) causes this error, adding -Wl,--export-all-symbols fixed the problem for me.

That’s very odd. There was a change in binutils 2.34 which should have made -Wl,--dynamicbase actually work correctly for executables. -Wl,--export-all-symbols sort of sounds like it would work around the issue that was solved in 2.34.

I recently authored a patch against binutils upstream to make dynamicbase, nxcompat, and high-entropy-va (on x64) the default, and this project is currently in the process of enabling those flags and testing for breakage in packages. Hopefully this will help suss out any issues with them. Whatever is going on in this issue (and it may be several different things that just happen to result in ld failing with error code 5), sounds like an issue in binutils upstream and not in the packaging of binutils here.

For me its still a problem without the additional linker flag mentioned above. With binutils v2.30 it works flawless, binutils v2.34 results in ld returned 5 exit status. Probably the behaviour of ld has changed…

@droidmonkey I experienced the same linker error for some but not all keepassx unit tests. It seems that ASLR (-Wl,--dynamicbase) causes this error, adding -Wl,--export-all-symbols fixed the problem for me.

KeePassXC is experiencing this same problem with binutils 2.34. Just downgraded to 2.33 and the problem went away immediately. To reproduce simply checkout our repository (develop branch) and build keepassxc-proxy (make keepassxc-proxy) in release mode.

https://github.com/keepassxreboot/keepassxc

I narrowed down the fault to the combination of linker parameters: -Wl,--nxcompat -Wl,--dynamicbase -Wl,--high-entropy-va. When these parameters are removed the fault goes away using v2.34.