OSX gobjdump corrupts executable

432 views Asked by At

I am trying to create the equivalent of pdb files on windows to have builds with separate debug info files. I installed and tried using gobjdump to remove debug information from a small hello world program (testDebugging). I built the code using eclipse and the binary was working fine.

The moment I run gobjcopy --strip-debug testDebugging, the size of the binary reduced . But when I now try to run the binary it fails with "-bash: ./testDebugging: Malformed Mach-o file"

There is no error messages even if the verbose option is on. Any pointers on why such a basic feature is broken? Version info : GNU objcopy (GNU Binutils) 2.24

Man command says the below .

. "foo" then...

       1.<Run "objcopy --only-keep-debug foo foo.dbg" to>
           create a file containing the debugging info.

       1.<Run "objcopy --strip-debug foo" to create a>
           stripped executable.

       1.<Run "objcopy --add-gnu-debuglink=foo.dbg foo">
           to add a link to the debugging info into the stripped
           executable.
1

There are 1 answers

2
Droppy On BEST ANSWER

What about using dsymutil instead?

$ xcrun dsymutil binfile -o binfile.dSYM

(This assumes you're using the Xcode command line tools).