Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is difference between objcopy and dsymutil?

Are these two commands on linux:

objcopy --only-keep-debug foo foo.dbg
objcopy --add-gnu-debuglink=foo.dbg foo

equivalent to below on mac

dsymutil <binary> -o <binary>.dSYM

Equivalent in the sense that,

  1. It creates a standalone debug info file.
  2. It create a link between the executable and debug info file.

Then for stripping

is the commands on linux:

objcopy --strip-debug foo

OR

strip -g <binary>

equivalent to below on mac

strip -S <binary>
like image 691
Abhishek Jain Avatar asked Oct 19 '15 12:10

Abhishek Jain


1 Answers

The --only-keep-debug part of the objcopy does functionally the same thing as dsymutil.

There isn't any tool to record the binary location in the dSYM. Rather the dSYM & the binary share a common UUID, and clients that want to find symbol files use the DebugSymbols framework, which uses various tricks (e.g. a Spotlight importer, search paths, a "dSYM finding external script", etc) to find the separate debug file. So there isn't a need for an equivalent to --add-gnu-debuglink.

The mac version of strip -S does strip debug information the same way that the binutils version does. The difference is that strip -S on OS X won't actually decrease the size of the binary much. On OS X, the debug information is always kept out of the executable - residing either in the .o files or in the dSYM. The executable only has a small "debug map" that tells lldb or dsymutil how to link the dwarf from the .o files. strip -S only has to remove the debug map.

like image 170
Jim Ingham Avatar answered Oct 24 '22 10:10

Jim Ingham