Commit f853179c authored by Simon McVittie's avatar Simon McVittie
Browse files

utils: Add functions to compare symbols and versions with libelf

When two libraries have the same numeric tail we were not able to reliably
determine which one was the newer. In particular, many distributions
install as a regular file, rather than a symlink to a
versioned name, so library_cmp_by_name() can't work.

These functions let us also check the library's version-definitions and
the individual symbols, to make a more nuanced decision.

Implementation originally by Ludovico de Nittis, adapted by Simon
McVittie to fit the same signature as library_cmp_by_name() so that
we can call the comparison functions via function pointers, to set up
different comparison weights for each library if necessary. This version
also includes Simon's changes to ignore uninteresting symbols for the
purposes of library comparison, with a list of uninteresting symbols
that are part of various architectures' ABIs, taken from dpkg-gensymbols.

Co-authored-by: Ludovico de Nittis's avatarLudovico de Nittis <>
Signed-off-by: Simon McVittie's avatarSimon McVittie <>
parent 6013fb6e
......@@ -467,7 +467,7 @@ tests_utils_t_SOURCES = tests/utils.c \
tests/test-helpers.h \
utils/library-cmp.c \
tests_utils_t_LDADD = utils/ $(GLIB_LIBS)
tests_utils_t_LDADD = utils/ $(GLIB_LIBS) $(LIBELF_LIBS)
test_scripts = tests/ \
tests/ \
This diff is collapsed.
......@@ -22,3 +22,15 @@ int library_cmp_by_name( const char *soname,
const char *container_root,
const char *provider_path,
const char *provider_root );
int library_cmp_by_symbols( const char *soname,
const char *container_path,
const char *container_root,
const char *provider_path,
const char *provider_root );
int library_cmp_by_versions( const char *soname,
const char *container_path,
const char *container_root,
const char *provider_path,
const char *provider_root );
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment