Possible to compress debug symbols in a PE exe? (ld final link failed: bad value)
Hannes Domani
ssbssa@yahoo.de
Tue Mar 1 20:50:10 GMT 2022
Am Dienstag, 1. März 2022, 21:17:57 MEZ hat Hans L via Binutils <binutils@sourceware.org> Folgendes geschrieben:
> 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 ?)
I'm not sure why compression while linking isn't working for PE files,
but I am able to compress the final executable with
`objcopy --compress-debug-sections SOME.EXE`, maybe you can use this as well.
Regards
Hannes
More information about the Binutils
mailing list