Can gdb debug win32 native program?

DJ Delorie
Thu Jun 29 20:38:00 GMT 2000

Warning: cross-posted to cygwin and binutils.  Remove at least one
when replying!

> bash-2.04$ objdump -p //E/WINNT/SYSTEM32/calc.exe
> objdump: //E/WINNT/SYSTEM32/calc.exe: File format not recognized

OK, I debugged it and I know why it's failing, but I don't have a fix.

To make it short: 99% of all PE programs have the same sized
structures at the beginning of the program file.  Some don't.  BFD
tries hard to adjust to the varying sizes, but it appears that in your
case it doesn't do it right, and ends up reading a structure from the
wrong place in the file.  If you care to debug it, look for
pe_bfd_object_p() in bfd/peicode.h; the test that fails is in
coff_bad_format_hook() in bfd/coffcode.h.  However, I suspect I will
be debugging this one myself :-( but not tonight.

I had to scan my whole system32 directory to find a program that
failed this way, too!

More information about the Binutils mailing list