Glibc provides backtrace()
and backtrace_symbols()
for accessing a stack trace from within a process, independent of debugging symbols. However, per this question, a statically linked binary will omit the necessary .dynsym
section even if the flag -rdynamic
has been passed.
I'm aware of methods based on debugging symbols, using libdwarf
or libdw
from ELF utils. For reasons of binary size (and associated compilation time) and licensing (for the particular mentioned libraries), I'd prefer not to rely on those.