dladdr1 - Linux


Overview

dladdr1 is a command-line tool for retrieving information about a specified memory address in a running process. It provides detailed insight into the virtual memory layout and allows users to identify the associated function, object file, and symbol information.

Syntax

dladdr1 [options] <address>

Options/Flags

  • -s, –symbol: Print only the symbol name.
  • -o, –object: Print only the object file name.
  • -f, –function: Print only the function name.
  • -l, –long: Print all information (object file, function, symbol).
  • -p, –pid: Specify the process ID to analyze (default: current process).
  • -d, –demangle: Demangle symbol names (if applicable).
  • -e, –error: Print error messages when no information is found.
  • -h, –help: Print help message and exit.

Examples

Simple usage:

dladdr1 0x12345678

Print only the function name:

dladdr1 -f 0x12345678

Print information for a specific process:

dladdr1 -p 12345 0x12345678

Demangle symbol names:

dladdr1 -d 0x12345678

Common Issues

  • No information found: This can occur when the address is invalid or the process is not running. Use the -e flag to suppress these errors.
  • Ambiguous symbol name: If multiple symbols match the address, only one will be displayed. Consider using nm or readelf to resolve the ambiguity.

Integration

dladdr1 can be used in conjunction with other commands for advanced analysis:

  • gdb: Use info address to print the dladdr1 output for a specific address in a debugged process.
  • grep: Filter dladdr1 output to find symbols or functions of interest.
  • awk: Parse dladdr1 output to extract specific information.

Related Commands

  • nm
  • readelf
  • objdump
  • gdb