../

Ripping and Stripping Debug Symbols with Binutil tools

In the world of software development, compiled binaries often come packed debug symbols. These symbols provide valuable information for debugging purposes, like function names and variable locations and in some scenarios even the source code. But for final deployments, they’re unnecessary and can significantly increase file size and security risks.

This is where binutil tools comes in, the GNU Binutils are a collection of programming tools maintained by the GNU Project for working with executable code including assembly, linking and many other development operations. This collection contains tools like:

In this post, we’ll explore how to use objcopy and strip tools to achieve our two key goals:

What is objcopy and strip?

Difference between Ripping and Stripping

1. Ripping off debug symbols off a binary (objcopy)

If you want to keep the debug information for potential future use, you can extract it into a separate file using the --only-keep-debug flag

objcopy --only-keep-debug myprogram debug_symbols.dbg

This creates a file named debug_symbols.dbg that contains only the stripped debug symbols. After ripping the symbol file from the binary the symbol file is still in the binary we only extracted a copy of the symbol file.

Demo:

2. Stripping off debug symbols off a binary (strip)

Stripping will remove the symbols from the binary without taking a copy of it

strip --strip-debug myprogram -o myprogram_without_symbols
Demo:

In the above demo we can see that even though we stripped debug symbols, some information like function names are still in the non-debugging symbols section.

In order to get rid of that info too, we can strip off everything including default sysmbols except the necessary things to load a binary using the --strip-unneeded flag.

strip --strip-debug --strip-unneeded myprogram -o myprogram_without_any_symbols
Demo:

Benefits of Stripping:

There are several advantages to stripping debug symbols:

Tags: /debugging/ /symbol-files/ /objcopy/ /strip/ /gnu/ /binutils/