dpkg-gensymbols - Linux


Overview

dpkg-gensymbols generates symbol files (.syms) for use in linking shared libraries. It takes a binary file as input and parses its symbol table to create a symbol file. Symbol files contain information about the symbols exported by a library, and are used by linkers to resolve external references.

Syntax

dpkg-gensymbols [options] <binary-file> [<output-file>]

Options/Flags

  • -o, --output=: Specify an output file name. The default is <binary-file>.syms.
  • -s, --soname=: Override the SONAME of the binary file.
  • -l, --local: Generate a local symbol file, which only contains symbols that are not defined by other shared libraries.
  • -e, --exclude=: Exclude symbols matching the regular expression from the symbol file.

Examples

Generate a symbol file for the shared library libfoo.so:

dpkg-gensymbols /usr/lib/libfoo.so

Generate a local symbol file for the binary myprogram:

dpkg-gensymbols -l myprogram

Common Issues

  • Missing symbol files: If a shared library does not have a corresponding symbol file, the linker may fail to resolve external references. Always generate symbol files for shared libraries before linking them into other programs.
  • Incorrect SONAME: The SONAME of a shared library must match the name specified in its symbol file. If the SONAMEs do not match, the linker will fail to find the symbols.

Integration

dpkg-gensymbols is commonly used in conjunction with other packaging tools, such as:

  • dpkg: The Debian package manager uses dpkg-gensymbols to generate symbol files for shared libraries included in packages.
  • ldconfig: The ldconfig tool uses symbol files to update the shared library cache and resolve dynamic linker dependencies.

Related Commands

  • readelf: Displays information about ELF files, including their symbol tables.
  • objdump: Dumps the contents of object files, including their symbol tables.
  • strip: Removes symbol information from ELF files.