ABI Compliance Checker

ABI Compliance Checker (ACC) is an easy-to-use tool for checking backward binary compatibility (BC) of a shared C/C++ library. It checks header files along with shared libraries of old and new versions and analyzes changes in Application Binary Interface (ABI) that may cause compatibility problems: changes in calling stack, v-table changes, removed symbols, etc. Breakage of the binary compatibility may result in crashing or incorrect behavior of applications built with an old version of the library if they run on a new one. The tool is intended for library developers and operating system maintainers who are interested in ensuring binary compatibility, i.e. allow old applications to run with newer library versions without the need to recompile.

  See also: Upstream Tracker for C/C++ libraries.

Contents

Downloads

The latest release can be downloaded from this page.

License

This program is free software. You may use, redistribute and/or modify it under the terms of either the GNU GPL or LGPL.

Supported Platforms

GNU/Linux, FreeBSD, Haiku (BeOS), Mac OS X, MS Windows (Xp, Vista, 7).

System Requirements

  • Linux:
    • GCC (3.0-4.5.2, recommended 4.0 or newer)
    • binutils (c++filt, readelf, objdump)
    • Perl (base)
    • WARNING: if you are using ccache program (i.e. gcc points to /usr/lib/ccache/gcc) then it should be newer than 3.1.2 or disabled.
  • MS Windows:
    • MinGW (gcc.exe, c++filt.exe)
    • Active Perl
    • MS Visual C++ (dumpbin.exe, undname.exe, cl.exe)
    • add gcc.exe path (C:\MinGW\bin\) to your system PATH variable
    • run vsvars32.bat script (C:\Microsoft Visual Studio 9.0\Common7\Tools\)
  • Mac OS X:
    • Xcode (gcc, c++filt, otool)

Detectable Compatibility Problems

The tool searches for the following list of changes in the API that may break binary compatibility:

  • Removed Symbols (functions, global data)
  • Problems with Data Types
    • Structures:
      • added/removed fields (change of structure layout)
      • change of size
      • changes in fields (recursive analysis)
    • Classes:
      • added/removed virtual functions (change of v-table layout)
      • change of virtual function position
      • overridden virtual functions
      • changes in base classes (recursive analysis)
    • Enumerations:
      • change of a member value
      • renamed members
      • removed members
  • Problems with Symbols
    • Stack Frame:
      • added/removed parameters
      • change of parameter type
    • Other:
      • changed attributes
      • change of return value type
      • incorrect version change
      • change of default parameter value
  • Problems with Constants (#defines)
    • changed value
  • Problems with Implementation
    • changes in disassembled binary code

You can see detailed problem descriptions in the HTML ABI compliance report (see example) generated by the tool.

Usage

For using the tool, you should provide the XML descriptors for two library versions: 1st_version.xml and 2nd_version.xml files. Library descriptor is a simple XML-file that specifies version number, paths to header files and shared libraries and optionally some other information. An example of the descriptor is the following (0.3.4.xml):

<version>
    0.3.4
</version>

<headers>
    /usr/local/libssh/0.3.4/include/
</headers>

<libs>
    /usr/local/libssh/0.3.4/lib/
</libs>

Compare Libraries

Command to compare two versions of a library:
   perl abi-compliance-checker.pl -l <library_name> -d1 <1st_version.xml> -d2 <2nd_version.xml> 

The compatibility report will be generated to:
   compat_reports/<library_name>/<1st_version>_to_<2nd_version>/abi_compat_report.html 

Check Applications Portability

The ACC tool can be used by ISVs for checking applications portability to new library versions by specifying of its binary using -app option:
   perl abi-compliance-checker.pl -l <library_name> -d1 <older.xml> -d2 <newer.xml> -app <application> 

Found issues can be taken into account when adapting the application to a new library version.

Dump Library ABI to TXT file

To compare library versions that are not co-existed on one machine you can dump ABI to gzipped TXT format file using -dump option:
   perl abi-compliance-checker.pl -l <library_name> -dump <some_version.xml> 

The ABI dump will be generated to:
   abi_dumps/<library_name>/<library_name>_<some_version>.abi.tar.gz 

Then transfer and pass it instead of the library descriptor:
   perl abi-compliance-checker.pl -l <library_name> -d1 <v1_dump.tar.gz> -d2 <v2_dump.tar.gz> 

Compare Operating Systems

The first step is to dump all the C/C++ libraries in both operating systems using the following command:
   perl abi-compliance-checker.pl -dump-system <name> -sysroot <root> 

The system ABI dump will be generated to:
   sys_dumps/<name>/<arch>/ 

The second step is to compare two dumps:
   perl abi-compliance-checker.pl -cmp-systems -d1 sys_dumps/<name1>/<arch> -d2 sys_dumps/<name2>/<arch> 

The compatibility report will be generated to:
   sys_compat_reports/<name1>_to_<name2>/<arch>/abi_compat_report.html 

See example of compatibility report for Maemo OS between 4.1.2 and 5.0 versions generated by the tool.

Command-Line Options

See the list of all options on this page.

Examples

Check the libssh library versions for ABI compatibility:
   perl abi-compliance-checker.pl -l libssh -d1 0.3.4.xml -d2 0.4.0.xml 

The compatibility report will be generated to:
   compat_reports/libssh/0.3.4_to_0.4.0/abi_compat_report.html 

Dump library ABI:
   perl abi-compliance-checker.pl -l libssh -dump 0.3.4.xml 

The ABI will be dumped to:
   abi_dumps/libssh/libssh_0.3.4.abi.tar.gz 

Use previously dumped ABI:
   perl abi-compliance-checker.pl -l libssh -d1 libssh_0.3.4.abi.tar.gz -d2 0.4.0.xml 

Check application (csync) portability between libssh versions:
   perl abi-compliance-checker.pl -l libssh -d1 0.3.4.xml -d2 0.4.0.xml -app /usr/bin/csync 

Dump all the C/C++ libraries in Maemo 4.1.2:
   /home/maemo/4.1.2/scratchbox/login 

   perl abi-compliance-checker.pl -dump-system "Maemo-4.1.2" -sysroot / 

The system ABI dump will be generated to:
   sys_dumps/Maemo-4.1.2/arm/ 

Check the Maemo OS for backward compatibility between 4.1.2 and 5.0 versions:
   perl abi-compliance-checker.pl -cmp-systems -d1 sys_dumps/Maemo-4.1.2/arm/ -d2 sys_dumps/Maemo-5.0/arm/ 

The compatibility report will be generated to:
   sys_compat_reports/Maemo-4.1.2_to_Maemo-5.0/arm/abi_compat_report.html 

Tutorial

An excellent tutorial "ABI: stability check" is available at Les RPM de Remi Blog.

Report Format

See examples of compatibility report:

The report consists of:

  • Test Info - The library name and compared version numbers. Environment info: GCC version and CPU architecture.
  • Test Results - Verdict on binary compatibility. Number of header files, shared libraries, symbols and data types checked by the tool.
  • Problem Summary - Classification of binary compatibility problems.
  • Added Symbols - List of added symbols.
  • Removed Symbols - List of removed symbols.
  • Problems with Data Types - List of binary compatibility problems caused by changes in data types (divided by the severity level: High, Medium and Low). List of affected symbols.
  • Problems with Symbols - List of binary compatibility problems caused by changes in symbol parameters or attributes (divided by the severity level).
  • Problems with Constants - List of changed constants (#defines).
  • Problems with Implementation - List of changes in disassembled binary code. Use -check-implementation option to enable this section.

Verdict on Compatibility

If the tool detected problems with high or medium level of severity or at least one removed symbol then the compatibility verdict is incompatible (otherwise compatible). Low-severity problems can be considered as warnings and don't affect the compatibility verdict unless the -strict option is specified.

Error Codes

This is the list of supported exit codes:

  • 0 - Compatible. The tool has run without any errors.
  • 1 - Incompatible. The tool has run without any errors.
  • 2 - Common error code (undifferentiated).
  • 3 - A system command is not found.
  • 4 - Cannot access input files.
  • 5 - Cannot compile header files.
  • 6 - Headers have been compiled with minor errors.
  • 7 - Invalid input ABI dump.
  • 8 - Unsupported version of input ABI dump.

FAQ

  • What is an ABI and how does it differ from an API?

An Application Binary Interface (ABI) is the set of supported run-time interfaces provided by a software component or set of components for applications to use, whereas an Application Programming Interface (API) is the set of build-time interfaces. The ABI may be defined by the formula:

   library API + compiler ABI = library ABI
  • Why does this tool need both shared libraries and header files to check ABI compliance?

Without header files it is impossible to determine public symbols in ABI and data type definitions. Without shared libraries it is impossible to exactly determine symbols that are included in ABI for the specified library and also impossible to detect added/removed symbols.

Similar Tools

  1. icheck - C interface ABI/API checker,
  2. BCS - The Symbian Binary Compatibility Suite,
  3. shlib-compat - ABI compatibility checker that uses DWARF debug info,
  4. qbic - A tool to check for binary incompatibilities in Qt4 Toolkit,
  5. chkshlib, cmpdylib, cmpshlib - compare symbols presence.

Bugs

Please post your bug reports, feature requests and questions to the issue tracker or send directly to abi-compliance-checker@linuxtesting.org

Maintainers

The tool was developed by the Russian Linux Verification Center at ISPRAS.
Andrey Ponomarenko is the leader of this project.

Sponsors

The development of this tool is sponsored by Nokia.

Logo nokia.gif

Credits

We would like to thank everyone who has contributed to the success of this project!

Articles

Here is the list of articles about shared libraries and ensuring binary compatibility:

  1. KDE TechBase, “Binary Compatibility Issues With C++”, “Binary Compatibility Examples”
  2. codesourcery.com, "Itanium C++ ABI"
  3. Josh Faust, "ABI Compatibility"
  4. Les RPM de Remi - Blog, "ABI : stability check"
  5. Agner Fog, “Calling conventions for different C++ compilers and operating systems”
  6. Andreas Jonsson, "Calling conventions on the x86 platform"
  7. Thiago Macieira, “Some thoughts on binary compatibility”
  8. Pavel Shved, Denis Silakov, "Binary Compatibility of C++ shared libraries on GNU/Linux"
  9. David J. Brown and Karl Runge, "Library Interface Versioning in Solaris and Linux"
  10. HP.com, "Steps to Version Your Shared Library"
  11. developer.apple.com, "Macintosh C/C++ ABI Overview"
  12. Chad Austin, “Binary-compatible C++ Interfaces”
  13. GNU.org, "ABI Policy and Guidelines", "Binary Compatibility"
  14. Stephen Clamage, "Stability of the C++ ABI: Evolution of a Programing Language"
  15. Debian Library Packaging guide, "When binary compatibility breaks"
  16. Sergey Ayukov, "Shared libraries in Linux: growing pains or fundamental problem?"
  17. Computer Desktop Encyclopedia, "Application Binary Interface"
  18. Linux.org, “Program Library HOWTO”
  19. Ulrich Drepper, "How To Write Shared Libraries"
  20. Mike Hearn, “Writing shared libraries”
  21. KDE TechBase, “Library Code Policy”
  22. Peter Potrebic, “What's the Fragile Base Class (FBC) Problem?”
  23. OoCities.org, “The amazing world of library incompatibility”
  24. Forum.Nokia, “The Theory of Binary Compatibility”
  25. symbian.org, "Preserving Compatibility"
  26. Ponomarenko A., Rubanov V., VALID 2010 "Automated Verification of Shared Libraries for Backward Binary Compatibility"
  27. FreeStandards.org, Generic ABI (gABI) Standard, "ELF and ABI Standards"
  28. Processor Supplement ABI (psABI) documents: Intel386, AMD64, PowerPC, S/390, Itanium, ARM, MIPS, SPARC, PA-RISK, M32R