Yocto layer for ELF binary compliance validation.
This layer is a fork of https://github.com/clio-project/meta-binaryaudit with further changes.
- URI: https://git.openembedded.org/openembedded-core
- Branch: scarthgap|whinlatter|wrynose|blacksail
- Adarsh Jagadish Kamini adarsh.jagadish.kamini@est.tech
Send patches as pull requests against the main branch of
https://github.com/Nordix/meta-binaryaudit. See CONTRIBUTING.md for the
commit message format.
All files in this layer are MIT licensed, see LICENSE.MIT.
The ABI compliance mechanism relies on libabigail.
The included libabigail recipe is configurable through PACKAGECONFIG. See the recipe for the available options.
Enable the ABI check by adding the abicheck class to INHERIT in local.conf:
INHERIT += "abicheck"The class adds a do_gather_abixml task after do_install which writes an
ABI dump of every shared library to buildhistory. Keep the buildhistory of a
build to use it as a baseline for later builds.
After the baseline build, point the layer at its buildhistory directory:
BINARY_AUDIT_REFERENCE_BASEDIR = "/path/to/buildhistory.baseline"The baseline must be created with the same major version of libabigail as the current build. abidiff cannot compare dumps from libabigail 2.x with dumps from 3.0, so regenerate the baseline after upgrading.
The comparison runs as part of
package QA and
uses abidiff.
Incompatible ABI changes are reported as abi-changed warnings by default.
To make them build errors instead, add the following to local.conf:
ERROR_QA:append = " abi-changed"
WARN_QA:remove = " abi-changed"Set ABI_CHECK_SKIP = "1" in a recipe to skip it.
To enable abicheck for a single build without modifying local.conf, use the
-R flag to read the provided conf fragment:
bitbake -R /path/to/meta-binaryaudit/conf/abicheck-enable.conf <target>To set the reference baseline from the environment, the variable has to be allowed through first:
export BB_ENV_PASSTHROUGH_ADDITIONS="$BB_ENV_PASSTHROUGH_ADDITIONS BINARY_AUDIT_REFERENCE_BASEDIR"
BINARY_AUDIT_REFERENCE_BASEDIR=/path/to/buildhistory.baseline \
bitbake -R /path/to/meta-binaryaudit/conf/abicheck-enable.conf <target>To make ABI changes build errors (e.g. in a gating CI job), add a second fragment:
bitbake -R /path/to/meta-binaryaudit/conf/abicheck-enable.conf \
-R /path/to/meta-binaryaudit/conf/abicheck-errors.conf <target>The two conf fragments are:
conf/abicheck-enable.conf: addsabichecktoINHERITandnativesdk-libabigailto the SDKconf/abicheck-errors.conf: movesabi-changedfromWARN_QAtoERROR_QA
At the end of each build, all ABI dumps are also packed into a single archive:
${BUILDHISTORY_DIR}/${DISTRO}-${DISTRO_VERSION}-abixmls.tar.zst
Keep this archive instead of the whole buildhistory directory to compare
against later builds. The scripts under scripts/ compare two archives (or
two buildhistory directories) and generate an HTML and JSON report:
python3 scripts/abi_compare.py \
--ref-build old /path/to/old-abixmls.tar.zst \
--current-build new /path/to/new-abixmls.tar.zst > compare.log
python3 scripts/generate_abi_report.py compare.log report.htmlThe scripts need abidiff from libabigail on the host (or pass its path with
--abidiff) and the zstandard Python package. The host abidiff must be at
least the libabigail version the layer builds (3.0); abi_compare.py stops
with an error otherwise. See scripts.md for all options, merging per-arch
archives, and the bundled suppression files.
An ABI suppression specification file can be used to tell abidiff to ignore certain changes.
To use a global suppression file, set its path in local.conf:
BINARY_AUDIT_GLOBAL_SUPPRESSION_FILE = "/path/to/suppression.file"To add a suppression for one recipe, add the file to the recipe's SRC_URI
from a bbappend. The file name must match abi*.suppr. For example, for
openssl:
# openssl_%.bbappend
FILESEXTRAPATHS:prepend := "${THISDIR}/files:"
SRC_URI += "file://abi_openssl.suppr"The file is unpacked to the recipe's WORKDIR and passed to abidiff with
--suppr.