Commit f853179c authored by Simon McVittie's avatar Simon McVittie

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 libgcc_s.so.1 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 <ludovico.denittis@collabora.com>
Signed-off-by: Simon McVittie's avatarSimon McVittie <smcv@collabora.com>
parent 6013fb6e
......@@ -467,7 +467,7 @@ tests_utils_t_SOURCES = tests/utils.c \
tests/test-helpers.h \
utils/library-cmp.c \
utils/library-cmp.h
tests_utils_t_LDADD = utils/libutils.la $(GLIB_LIBS)
tests_utils_t_LDADD = utils/libutils.la $(GLIB_LIBS) $(LIBELF_LIBS)
test_scripts = tests/capture-libs.pl \
tests/symbols.pl \
......
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 );
Markdown is supported
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