dlvsym - Linux
Overview
dlvsym is a Linux command that extracts debugging symbols from dynamic shared objects (DSOs) to aid in debugging. It is commonly used to provide better debugging information for executables linked against these DSOs.
Syntax
dlvsym [options] <dso> [output file]
Options/Flags
- -a: Append to the output file instead of overwriting it.
- -c: Checksum the DSO and write the checksum to the output file.
- -D: Obtain system-wide symbols from
/proc/kallsyms
and add them to the output. - -j: Use multiple threads to accelerate processing.
- -p <process_id>: Extract symbols from a live process with the specified ID.
- -t: Print all types of symbols (default: only global and static symbols).
- -v: Verbose output, including a list of symbols extracted.
- -z: Compress the output file (default: uncompressed).
Examples
To extract symbols from the libfoo.so
DSO and save them to symbols.txt
:
dlvsym libfoo.so symbols.txt
To append symbols from libfoo.so
to the existing symbols.txt
file:
dlvsym -a libfoo.so symbols.txt
To extract symbols from a live process with ID 1234:
dlvsym -p 1234
Common Issues
-
Error:
dlvsym: <dso>: not found
Solution: Ensure that the specified DSO exists and is readable. -
Error:
dlvsym: <dso>: no symbols found
Solution: Check that the DSO contains debugging symbols. Some DSOs may be stripped of symbols for optimization purposes.
Integration
dlvsym can be integrated with other commands and tools for advanced debugging tasks. For example:
- objdump -t can be used to view the extracted symbols in a human-readable format:
dlvsym libfoo.so symbols.txt && objdump -t symbols.txt
- gdb can be used to debug an executable using the extracted symbols:
gdb -s symbols.txt <executable>
Related Commands
- nm – displays the symbol table of an object file or shared library.
- objdump – disassembles object files and displays their contents.
- strip – removes debugging symbols from object files and shared libraries.