TExcelTAD
Home › Reverse Engineering & Binary Analysis › Symbols, Stripping and What Remains

Symbols, Stripping and What Remains

A binary built with symbols tells you the name of every function and global variable; one built with debug information also tells you types, source lines and local variable names. Release binaries are usually stripped: the names are removed to save space (and sometimes in the hope of making analysis harder). An analyst needs to know exactly what stripping removes and, more importantly, what it can't remove, because the leftovers (imported function names, strings, unwind tables, build ids) are where the analysis of a stripped binary starts.

Definitions

  • .symtab: the full symbol table, every function and global with its address, size and type, including static ones. Used by linkers and debuggers, not needed to run the program.
  • .dynsym: the dynamic symbol table, only the symbols needed for dynamic linking: functions and variables imported from shared libraries, and those the binary exports. Needed at run time, so stripping can't remove it.
  • Symbol types in nm output: T/t code (upper case = global, lower case = local/static), D/d initialised data, B/b zero-initialised data (.bss), R/r read-only data, U undefined (imported), W weak.
  • Debug information (DWARF, sections .debug_*, from -g): types, line numbers, variables. Can be split into a separate file and linked by .gnu_debuglink or the build id.
  • strip: removes .symtab, .strtab and debug sections (--strip-all, the default for strip with no options), or only debug information (--strip-debug).

Before and after strip

The session builds a toy with a global variable, a static helper and an exported function, then compares what each tool sees before and after strip. It compiles at -O0 so the helper stays a separate function; at -O1 GCC would inline it and fold strlen of the constant path, and both names would vanish before strip even runs.

bash · try it yourself
cat > toy.c <<'SRC'
#include <stdio.h>
#include <string.h>
int request_count = 0;
static const char *SECRET_PATH = "/etc/toy/secret.conf";
static int checksum(const char *s) {          /* a static (local) helper */
    int h = 0;
    for (; *s; s++) h = h * 31 + (unsigned char)*s;
    return h;
}
int handle_request(const char *msg) {
    request_count++;
    return checksum(msg) ^ (int)strlen(SECRET_PATH);
}
int main(int argc, char **argv) {
    printf("%d\n", handle_request(argc > 1 ? argv[1] : "ping"));
    return 0;
}
SRC
gcc -O0 -g toy.c -o toy
cp toy toy-stripped && strip toy-stripped
echo "== nm toy (functions and data from the program itself)"
nm toy | grep -E ' [TtDdBbRr] ' | grep -vE ' _|frame_dummy|deregister|register_tm|completed' 
echo "== nm toy-stripped"
nm toy-stripped 2>&1
echo "== still there after strip"
echo "dynamic imports: $(nm -D toy-stripped | awk '$1=="U"{print $2}' | sed 's/@.*//' | sort | tr '\n' ' ')"
echo "strings:         $(strings -n 8 toy-stripped | grep toy)"
echo "unwind entries:  $(readelf --debug-dump=frames toy-stripped 2>/dev/null | grep -c FDE) FDEs in .eh_frame"
echo "build id:        $(readelf -n toy-stripped | awk '/Build ID/{print substr($3,1,8)}')..."
for f in toy toy-stripped; do printf '%-13s %6s bytes, %2s sections, file says: %s\n' "$f" \
  "$(stat -c %s $f)" "$(readelf -SW $f | grep -c '^  \[')" "$(file -b $f | grep -oE '(not )?stripped')"; done
== nm toy (functions and data from the program itself)
0000000000004010 d SECRET_PATH
0000000000001169 t checksum
00000000000011ae T handle_request
00000000000011f3 T main
000000000000401c B request_count
== nm toy-stripped
nm: toy-stripped: no symbols
== still there after strip
dynamic imports: __libc_start_main printf strlen
strings:         /etc/toy/secret.conf
unwind entries:  7 FDEs in .eh_frame
build id:        257f7a42...
toy            17936 bytes, 38 sections, file says: not stripped
toy-stripped   14480 bytes, 30 sections, file says: stripped

What strip removed: the names checksum, handle_request, request_count and SECRET_PATH, the debug information, and with it a large part of the file. What it couldn't remove:

  • Imported names (printf, strlen, __libc_start_main): the dynamic loader needs them.
  • Strings: the secret path is data the program uses.
  • Unwind tables (.eh_frame): each FDE (frame description entry) describes one function's address range so exceptions and stack traces work. Counting FDEs gives a rough function count (here 7: the program's three functions plus _start and one each for the .plt, .plt.got and .plt.sec stubs), and their start addresses are function boundaries, which tools such as Ghidra and IDA use to find functions in stripped files.
  • The build id: a hash of the build that links this file to its separate debug file, crash reports and package metadata.

Shipping without symbols, debugging with them

The standard practice is to ship stripped binaries and keep the debug information in a separate file, found by build id. The session splits the debug info out and shows gdb finding it again.

bash · try it yourself
printf 'int add(int a, int b) { return a + b; }\nint main(void) { return add(2, 3); }\n' > dbg.c
gcc -O0 -g dbg.c -o app
objcopy --only-keep-debug app app.debug
strip --strip-all app
objcopy --add-gnu-debuglink=app.debug app
printf 'app %s bytes, app.debug %s bytes\n' "$(stat -c %s app)" "$(stat -c %s app.debug)"
gdb -q -batch -ex 'info line add' -ex 'break add' -ex 'run' -ex 'info args' ./app 2>&1 | grep -vE '^\[|libthread|^
  

app 14432 bytes, app.debug 5448 bytes
Line 1 of "dbg.c" starts at address 0x1129 <add> and ends at 0x1137 <add+14>.
Breakpoint 1 at 0x1137: file dbg.c, line 1.
Breakpoint 1, add (a=2, b=3) at dbg.c:1
1	int add(int a, int b) { return a + b; }
a = 2
b = 3

The shipped app is small and has no names, yet gdb loads app.debug through the debuglink and shows source lines and arguments. Debian, Ubuntu, Fedora and Windows (PDB files on symbol servers) all do this at scale, and debuginfod servers serve debug files by build id over HTTP.

How analysts detect what remains

  • file says stripped or not stripped; readelf -S shows whether .symtab and .debug_* exist.
  • Function discovery in stripped files: entry point → __libc_start_main's first argument is main; .eh_frame FDEs give function boundaries; calls give more starts; library signatures name the statically linked library functions (Recognising Library Code).
  • Leaked names survive in other places: assertion messages with __func__, logging format strings, C++ RTTI type names, Go and Rust binaries' own metadata (Go keeps a function name table pclntab even when stripped, for its runtime).

How it is done right

  • Strip release binaries and archive the debug files by build id (for crash analysis), never on the public download server if you consider them sensitive.
  • Don't rely on stripping for secrecy. The secret path above was visible after strip. Secrets belong outside the binary (configuration with proper permissions, a secrets manager: see Secrets Management); the logic is visible to anyone with a disassembler, with or without names.
  • Check release artefacts in CI: file says stripped, no .debug_* sections, no unexpected exported symbols (nm -D --defined-only).

Pitfalls

  • strip on a shared library with --strip-all keeps exported dynamic symbols (needed) but removes local ones; use --strip-unneeded for libraries.
  • -s at link time (gcc -s) strips too; the binary was never unstripped.
  • Static binaries (-static) have no .dynsym imports: the library code is inside the file, nameless after stripping, which makes them noticeably harder to read.
  • Symbol names can lie: anyone can name a function safe_copy. Names are hints, the code is the truth.

Practice

1. Which symbol table survives strip --strip-all, and why?

.dynsym: the dynamic loader needs it to resolve imports and exports at run time.

2. In the first session, why was checksum shown with a lower-case t?

It is static: a local symbol, visible only in its own file. Global functions are T.

3. A crash report from a stripped production binary contains only addresses. What do you need to turn them into function names and lines?

The matching debug file (found by build id), or the unstripped build of exactly the same source and flags; then addr2line -e app.debug -f <offset> or gdb.

Test yourself

What does U printf in nm output mean?

  1. printf is defined in this file
  2. printf is undefined here: it is imported from a shared library
  3. printf is unused
  4. printf is a static function

Which of these does stripping NOT remove?

  1. The names of static functions
  2. The debug line information
  3. Imported function names and string literals
  4. The .symtab section

Why are .eh_frame FDEs useful in a stripped binary?

  1. They contain the source code
  2. Each one describes a function's address range, giving function boundaries
  3. They contain passwords
  4. They list imports

How did gdb find source information for the stripped app?

  1. It decompiled the code
  2. Through the .gnu_debuglink to the separate app.debug file
  3. From the Internet
  4. It guessed