PE destructors create crashes in binutils itself

Jason A. Donenfeld
Sun Jun 2 10:54:00 GMT 2019

Hey Nick,

In b0daac83, you fixed static constructors and destructors on
PE/mingw. This means that in 2.30, destructors are broken, and in
>=2.31, they're fixed. It turns out that binutils itself (ld.exe,
windres.exe, etc) crashes if linked by a binutils >=2.31. Runtime
execution works fine, but just before exiting, the program crashes and
triggers the various Windows crash detector things and exits with a
non-zero exit code.

I built a binutils 2.32 with this ugly patch -- . It basically re-breaks 2.32's
destructor by restoring the incorrect 2.30 behavior. (I probably could
have just deleted the destructor section from that file and
accomplished the same.) I can confirm that this "works", and using it
to build a PE binutils results in one that doesn't crash at exit for
the various utilities. Obviously this isn't a proper fix, though.

Do you have any ideas why the destructor logic in binutils itself
would be crashing on mingw/windows/PE? This is something we're running
into with the toolchains over on


More information about the Binutils mailing list