Skip to main content
Redhat Developers  Logo
  • Products

    Featured

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat OpenShift AI
      Red Hat OpenShift AI
    • Red Hat Enterprise Linux AI
      Linux icon inside of a brain
    • Image mode for Red Hat Enterprise Linux
      RHEL image mode
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • Red Hat Developer Hub
      Developer Hub
    • View All Red Hat Products
    • Linux

      • Red Hat Enterprise Linux
      • Image mode for Red Hat Enterprise Linux
      • Red Hat Universal Base Images (UBI)
    • Java runtimes & frameworks

      • JBoss Enterprise Application Platform
      • Red Hat build of OpenJDK
    • Kubernetes

      • Red Hat OpenShift
      • Microsoft Azure Red Hat OpenShift
      • Red Hat OpenShift Virtualization
      • Red Hat OpenShift Lightspeed
    • Integration & App Connectivity

      • Red Hat Build of Apache Camel
      • Red Hat Service Interconnect
      • Red Hat Connectivity Link
    • AI/ML

      • Red Hat OpenShift AI
      • Red Hat Enterprise Linux AI
    • Automation

      • Red Hat Ansible Automation Platform
      • Red Hat Ansible Lightspeed
    • Developer tools

      • Red Hat Trusted Software Supply Chain
      • Podman Desktop
      • Red Hat OpenShift Dev Spaces
    • Developer Sandbox

      Developer Sandbox
      Try Red Hat products and technologies without setup or configuration fees for 30 days with this shared Openshift and Kubernetes cluster.
    • Try at no cost
  • Technologies

    Featured

    • AI/ML
      AI/ML Icon
    • Linux
      Linux Icon
    • Kubernetes
      Cloud icon
    • Automation
      Automation Icon showing arrows moving in a circle around a gear
    • View All Technologies
    • Programming Languages & Frameworks

      • Java
      • Python
      • JavaScript
    • System Design & Architecture

      • Red Hat architecture and design patterns
      • Microservices
      • Event-Driven Architecture
      • Databases
    • Developer Productivity

      • Developer productivity
      • Developer Tools
      • GitOps
    • Secure Development & Architectures

      • Security
      • Secure coding
    • Platform Engineering

      • DevOps
      • DevSecOps
      • Ansible automation for applications and services
    • Automated Data Processing

      • AI/ML
      • Data Science
      • Apache Kafka on Kubernetes
      • View All Technologies
    • Start exploring in the Developer Sandbox for free

      sandbox graphic
      Try Red Hat's products and technologies without setup or configuration.
    • Try at no cost
  • Learn

    Featured

    • Kubernetes & Cloud Native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud icon
    • Java
      Java icon
    • AI/ML
      AI/ML Icon
    • View All Learning Resources

    E-Books

    • GitOps Cookbook
    • Podman in Action
    • Kubernetes Operators
    • The Path to GitOps
    • View All E-books

    Cheat Sheets

    • Linux Commands
    • Bash Commands
    • Git
    • systemd Commands
    • View All Cheat Sheets

    Documentation

    • API Catalog
    • Product Documentation
    • Legacy Documentation
    • Red Hat Learning

      Learning image
      Boost your technical skills to expert-level with the help of interactive lessons offered by various Red Hat Learning programs.
    • Explore Red Hat Learning
  • Developer Sandbox

    Developer Sandbox

    • Access Red Hat’s products and technologies without setup or configuration, and start developing quicker than ever before with our new, no-cost sandbox environments.
    • Explore Developer Sandbox

    Featured Developer Sandbox activities

    • Get started with your Developer Sandbox
    • OpenShift virtualization and application modernization using the Developer Sandbox
    • Explore all Developer Sandbox activities

    Ready to start developing apps?

    • Try at no cost
  • Blog
  • Events
  • Videos

Comparing ABIs for Compatibility with libabigail - Part 1

 

October 23, 2014
Dodji Seketeli
Related topics:
LinuxSecurity
Related products:
Developer Tools

Share:

    Introduction:  The challenges around ABI compatibility

    Ensuring the forward compatibility of application binary interfaces (ABIs) exposed by native shared libraries has been a kind of black art for quite some time, due to many factors.

    circles

    The scope of the term ABI is quite broad, even when it is restricted to shared software libraries. It encompasses low-level concepts like the binary format, the processor instructions set used in the binary, the calling convention of the operating system on a given processor architecture, as well as higher level considerations like the layout and size of the data types used by the entry points of the library.

    Even when considering only one binary format, one processor instruction set, and one calling convention, ensuring that changes in the source code will not impact the ABI of the shared library in an incompatible way is a challenging proposition.

    Let's consider the particular use case of programmers regularly releasing new versions of the system shared software library they are working on. They obviously want to ensure that applications built against older versions of the library will continue to work when they use the newer versions of the same library.

    Ideally, they want to know of any ABI differences between the two versions of their library in a sufficiently meaningful way such that any incompatible differences can be easily spotted during reviews.

    This article is the first in a series of two articles about how we used tools built upon the libabigail project to review the ABI differences of the standard C++ shared library across Red Hat Enterprise Linux versions 6.x and 7.x to the latest release.

    The libabigail project is still in its early days but it has already been quite useful in doing this ABI compatibility analysis.

    Reviewing ABI differences with abidiff

    In the Free Software world, developers generally review source code changes by reading a flat textual representation of the source code change. That representation usually is the output of the GNU diff tool.

    Rather than reviewing source code changes, we want to review ABI changes in a way that makes it easy for developers not only to spot the incompatible changes, but also to understand which source code change created a given ABI change.

    This is where the abidiff tool comes into play. Given two ELF shared libraries and their debug information, the tool emits a textual representation of their ABI differences.

    By analyzing the debug information of the ELF libraries, abidiff constructs a representation of the defined functions and variables they export. That representation obviously includes the types of these global variables and functions. Then abidiff compares the variables and functions exported by the two libraries and emits a textual report about the functions and variables that were removed or added to the first library, as well as functions and variables whose type signature hasn't changed, but might be impacted by a layout, size, or other change in a sub-type.

    Getting and Building abidiff

    Sources for abidiff can be downloaded from the libabigail git repo, per the instructions at that link. Building instructions can also be found on that page. You may find you need to install the elfutils-devel package prior to building.

    Getting the RHEL 6.5 and 7.0 packages for libstdc++

    To review the ABI differences for the versions of libstdc++ from Red Hat Enterprise Linux 6.5 and 7, we first need to get the relevant RPM packages from the download section of the Red Hat Customer Portal. For simplicity, we perform the analysis for the x86_64 platform but we could have done it for any other platform for which the RPM packages are available.

    These RPM packages are:

    • libstdc++-4.4.7-4.el6.x86_64.rpm [RHEL] [Fedora]
    • gcc-debuginfo-4.4.7-4.el6.x86_64.rpm [RHEL] [Fedora]
    • libstdc++-4.8.2-16.el7.x86_64.rpm [RHEL] [CentOS] [Fedora]
    • gcc-base-debuginfo-4.8.2-16.el7.x86_64.rpm [RHEL] [CentOS] [Fedora]

    If you do not have access to the Red Hat Customer Portal you can get close enough RPM packages from the CentOS project, for instance, and similar libraries can be found in the Fedora Linux Distribution. When we say 'close enough', it's only for the pedagogic purpose of this article. CentOS binaries might otherwise differ from Red Hat Enterprise Linux binaries in subtle ways - and most notably are not backed up by Red Hat's enterprise support services. Anyway, if you want the CentOS binaries, or similar Fedora binaries, the hyperlinks on the package list above points to places from which you can download them. The rest of this article will assume you are using the RHEL binaries.

    For the sake of precision, let's assume that these packages are dropped into the /tmp/rpms directory on your local system. Let's also assume that you have cloned the source code of Libabigail into /tmp/libabigail, that you have compiled it and the resulting binaries are in /tmp/libabigail/build.

    We are going to extract the content of RHEL 6.5 RPM packages into /tmp/extracted/6.5 and RHEL 7 packages into /tmp/extracted/7. Here are the command-line instructions to type in your favorite terminal:

    mkdir -p /tmp/extracted/6.5 && cd /tmp/extracted/6.5
    rpm2cpio /tmp/rpms/libstdc++-4.4.7-4.el6.x86_64.rpm | cpio -id
    rpm2cpio /tmp/rpms/gcc-debuginfo-4.4.7-4.el6.x86_64.rpm | cpio -id
    mkdir /tmp/extracted/7 && cd /tmp/extracted/7
    rpm2cpio /tmp/rpms/libstdc++-4.8.2-16.el7.x86_64.rpm | cpio -id
    rpm2cpio /tmp/rpms/gcc-base-debuginfo-4.8.2-16.el7.x86_64.rpm | cpio -id
    

    Note that the exact .rpm names should match those you downloaded earlier. Now we should have the two libstdc++ libraries to compare at /tmp/extracted/6.5/usr/lib64/libstdc++.so.6 and /tmp/extracted/7/usr/lib64/libstdc++.so.6. Their respective debug information files are available in /tmp/extracted/6.5/usr/lib/debug and /tmp/extracted/7/usr/lib/debug.

    Running abidiff on libstdc++ binaries

    As input, abidiff mainly needs the two libraries to compare. In this particular case, as the libraries have their debug information split into separate files, and as these files are located at non-standard places, we need to tell the tool where to find them as well.

    First let's create a directory to store the resulting report of abidiff:

    mkdir /tmp/abidiff-results
    

    The abidiff command-line to perform the comparison is thus:

    /tmp/libabigail/build/tools/abidiff --debug-info-dir1 /tmp/extracted/6.5/usr/lib/debug --debug-info-dir2 /tmp/extracted/7/usr/lib/debug /tmp/extracted/6.5/usr/lib64/libstdc++.so.6 /tmp/extracted/7/usr/lib64/libstdc++.so.6 > /tmp/abidiff-results/libstdc++.so.abidiff
    

    Note that the path to abidiff may differ, depending on the path to which you installed Libabigail at build time.

    At this point, abidiff has emitted an ABI changes report in the text file located at /tmp/abidiff-results/libstdc++.so.abidiff.  We will analyze that output in the next article.  Stay tuned.

    Last updated: February 7, 2024

    Recent Posts

    • More Essential AI tutorials for Node.js Developers

    • How to run a fraud detection AI model on RHEL CVMs

    • How we use software provenance at Red Hat

    • Alternatives to creating bootc images from scratch

    • How to update OpenStack Services on OpenShift

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Products

    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform

    Build

    • Developer Sandbox
    • Developer Tools
    • Interactive Tutorials
    • API Catalog

    Quicklinks

    • Learning Resources
    • E-books
    • Cheat Sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site Status Dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Report a website issue