Possible to compress debug symbols in a PE exe? (ld final link failed: bad value)

Hans L thehans@gmail.com
Tue Mar 1 20:17:32 GMT 2022


I am cross compiling an application from Linux to Windows, where the build
uses MXE ( https://mxe.cc/ ) to bootstrap the GCC / Mingw-w64 based
cross-toolchain, as well as build various library dependencies which get
statically linked with the final executable.

The application builds successfully under normal conditions, but debug
builds are much larger than I would like them to be.  (About 1GB in size,
as opposed to 44MB without debug)
So I wanted to see if compression could help get the filesize down to
something more reasonable by adding gcc flag "-gz" in my CMakeLists.txt

This results in the build failing on the final step with the message:
  /mxe/usr/bin/x86_64-w64-mingw32.static.posix-ld: final link failed: bad
value

What is the meaning of this supremely unhelpful error message?
Is there something about PE format that is not capable of supporting
compressed DWARF symbols?
Have I run into a possible bug in ld?
Or something else entirely is going on? (random guess: must the statically
linked libraries themselves be built with the same "-gz" flag ?)

Thanks for any help,
Hans Loeblich


More information about the Binutils mailing list