Check out my first novel, midnight's simulacra!

Libc: Difference between revisions

From dankwiki
No edit summary
No edit summary
Line 35: Line 35:
               same name contained in libraries that have already been  loaded.
               same name contained in libraries that have already been  loaded.
               This flag is not specified in POSIX.1-2001.</pre>
               This flag is not specified in POSIX.1-2001.</pre>
==Generating a stack trace==
The <tt>backtrace</tt>, <tt>backtrace_symbols</tt> and <tt>backtrace_symbols_fd</tt> glibc calls can be used to generate a stack trace from within a program.
* <tt>backtrace</tt> generates a list of addresses
* <tt>backtrace_symbols</tt>, given the output of <tt>backtrace</tt>, will populate its argv-style return value with any symbols it can look up
In order to extract symbols, appropriate binaries must:
* not be stripped (or linked with -s), and
* be linked with -rdynamic/--export-dynamic