G++ creates unusable executable with -gdwarf-5 -Og, without any diagnostic issued

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

G++ creates unusable executable with -gdwarf-5 -Og, without any diagnostic issued

Tim Van Holder
Relevant package versions (all the current latest):


  *   Cygwin: 3.1.4
  *   binutils: 2.43+1git.de9c1b7cfe-1
  *   gcc-core, gcc-g++, libgcc1, libstdc++6: 9.3.0-1

Sample program (foo.cc):

#include <iostream>

using namespace std;

int
main(void)
{
  cout << "OK" << endl;
  return 0;
}

With a plain g++ foo.cc -o foo, I get a foo.exe that prints "OK".

However, with g++ -gdwarf-5 -Og foo.cc -o foo, I get a binary that reports
 -bash: ./foo.exe: cannot execute binary file: Exec format error
when run.
GDB can load the binary and show symbols just fine, but trying to run results in:
  Error creating process /cygdrive/.../foo.exe, (error 193).

Using -gdwarf-4 instead of -gdwarf-5 or dropping -Og makes the problem go away.
It also seems to be c++-specific; a C version of the sample program resulted in a working program
(could just be because a C++ program with iostream pulls in more, triggering the issue).
--
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple