abidiff - Linux


Overview

abidiff compares the ABIs of two shared libraries or executables. It can be used to detect ABI changes that may break compatibility between different versions of a library or application.

Syntax

abidiff [options] <old_library> <new_library>

Options/Flags

  • -h, –help: Display help and exit.
  • -V, –version: Display version information and exit.
  • -s, –symbols: Compare only symbols.
  • -d, –data: Compare only data.
  • -r, –relocations: Compare only relocations.
  • -a, –all: Compare all sections.
  • -t, –text: Compare only the text section.
  • -c, –changes: Print only the changes found.
  • -i, –ignore-symbols: Ignore unresolved symbols.
  • -e, –error-on-warning: Treat warnings as errors.

Examples

Simple ABI Comparison

abidiff /usr/lib/libfoo.so /usr/lib/libfoo-new.so

Compare Only Symbols

abidiff -s /usr/lib/libfoo.so /usr/lib/libfoo-new.so

Print Only the Changes

abidiff -c /usr/lib/libfoo.so /usr/lib/libfoo-new.so

Common Issues

Missing Symbols

If symbols are missing, try using the -i flag to ignore unresolved symbols.

Relocation Errors

If relocation errors occur, try using the -r flag to compare only relocations.

Integration

  • ldd: Can be used to display the shared libraries that an executable depends on. This information can be used with abidiff to compare the ABIs of different versions of a library.
  • readelf: Can be used to dump the ELF header and section information of a shared library or executable. This information can be useful for understanding the structure of the ABI.

Related Commands

  • diff
  • cmp
  • objdump