TotalView : TotalView Reference Guide : PART IV Platforms and Operating Systems : Platforms and Compilers : Maintaining Debug Information Separate from an Executable
Maintaining Debug Information Separate from an Executable
Because debug information embedded in an executable can be very large, some versions of Linux support stripping this information from the executable and placing it into a separate file. This file is then referenced within the executable using either a build ID section or a debug link section (or both) to identify the location and name of the separate debug file. The stripped image file will normally take up less space on the disk, and if you want the debug information, you can also install the corresponding .debug file.
The way this works with TotalView is controlled by a series of state variables and command line options discussed in Controlling Separate Debug Files.
Create this file on Linux systems that have an objcopy that supports the ‑ ‑add-gnu-debuglink and ‑ ‑only‑keep‑debug command-line options. If objcopy ‑ ‑help mentions these options, creating this file is supported. See man objcopy for more details.
To create a separate file containing debug information:
1. Create a .debug copy of the executable or shared library. This second file is a regular executable but will contain only debugging symbol table information, with no code or data.
2. Create a stripped copy of the image file, and add to the stripped executable a .gnu_debuglink section that identifies the .debug file.
NOTE: The technique for creating a build ID separate debug information file is different and more complex than that for creating a debug link. Consult your system documentation for how to create a separate debug information file using the build ID method.
3. Distribute the stripped image and .debug files separately.
For example:
 
objcopy --only-keep-debug hello hello.debug
objcopy --strip-all hello
objcopy --add-gnu-debuglink=hello.debug hello
The code above uses objcopy to:
1. Create a separate debug file for an executable hello named hello.debug, containing only debug symbols and information.
2. Strip the debug information from the hello executable.
3. Add a .gnu_debuglink section to the hello executable.