SBO::Lib::Solibs(3)

NAME
SBO::Lib::Solibs - Routines for evaluating ELF binaries and checking compatibility.

SYNOPSIS
  use SBO::Lib::Solibs qw/ solib_check /;

VARIABLES

  $match_mode
A variable indicating that the user is interested in files and packages depending on one or more libraries. It is set when the "--lib-search" flag is in use for sbocheck(1).

  @native_libs
An array with shared objects (solibs) of the native architecture in the ldconfig(1) cache. It is generated by solib_check() via update_known_solibs() if it is empty at the time of calling.

  %old_libs
A hash with a per-package list of apparently missing first-order shared object dependencies; each missing dependency comes with a list of files that link to it. This hash is generated when running solib_check().

  %per_cand, %x86_per_cand
Hashes with per-object lists of dynamically-linked files. They are used to produce the file lists in %old_libs, and are not exported.

  @libs_32
An array with 32-bit shared objects in the ldconfig(1) cache. Used only under 64-bit architectures, it is generated together with @native_libs by update_known_solibs().

  @not_opt_only
An array with packages with files outside of "/opt" that have missing solib dependencies.

SUBROUTINES

  decimalize
  my $decimal = decimalize($hex, $big_endian);

decimalize() takes a hex string and an indicator of whether big-endian processing is to be used, returning a decimal string.

  elf_links
  my ($elf_type, @cand_libs) = is_elf($file);

elf_links() takes a path and checks whether it is a dynamically-linked ELF binary; it returns 0 if not. Otherwise, it reads entries according to the elf(5) specification and returns 1 for a 64-bit ELF file, -1 for a 32-bit ELF file and an array of first-order shared object dependencies that do not exist on the system under an "rpath" or "runpath".

  initialize_perl
  initialize_perl();

initialize_perl() determines the installed major "perl" version, installation times for installed and removed "perl" packages and the date at which the installed major version was first built for the running Slackware architecture (if available). These values are used to perform the "perl" package test. There is no useful return value.

  initialize_python
  initialize_python();

initialize_python() determines the default installed "python2" and "python3" versions in the form e.g. "python3.12". There is no useful return value.

  initialize_ruby
  initialize_ruby();

initialize_ruby() determines the correct major version for "ruby" based on the "/usr/include/ruby-*" directory. There is no useful return value.

  installed_solibs
  my @pkg_solibs = installed_solibs($pkg);

installed_solibs() takes the name of a package file. It returns an array of shared object names that are installed as files or symlinks, or 0 if none exist.

  series_check
  my @series_good = series_check($pkg, @series);

series_check() takes the name of a package file and an array with one or more checks to perform. Available checks include "perl", "python" and "ruby" at this time.

Likely stock packages (i.e., untagged packages) are judged to be incompatible with system "perl" if they are older than the first "/usr/bin/perl*" binary of the installed major version added to Slackware. The relevant timestamps are stored in "/etc/sbotools/perl_vers". Other packages are compared with the earliest installation date of the installed major version, or the binary timestamp if unavailable.

"python" and "ruby" are judged to be incompatible if files associated with the wrong major version (e.g. "python-3.12" or "ruby-3.4*") are included.

Files in "/opt" are ignored.

The subroutine returns an array with results for the checks in alphabetical order, with 1 indicating apparent compatibility and 0 indicating apparent incompatibility.

  solib_check
  my $solibs_good = solib_check($pkg);

  my $solibs_good = solib_check($pkg, @search);

solib_check() takes the name of a package file and, optionally, an array of shared object names to search, and checks for the presence of any required first-order shared object dependencies as based on the @native_libs shared object array. It returns 1 if all required shared objects appear to be present and 0 otherwise.

If $match_mode is set, solib_check() instead returns 0 if any file in the package has a first-order dependency on a library named by the user, present or not.

Because elf_links() is called, performance is cache-dependent. It is best to call solib_check() judiciously.

  solib_present
  my $solib_present = solib_present($cand_lib, $pkg, @candidate_files);

solib_present() takes the name of the shared object to be checked, the name of a package file and an array with probable ELF files shipped by that package. It returns 1 if the shared object appears to be present and 0 if it does not.

Please note that the known shared object array @native_libs (and @libs_32 if running on a 64-bit architecture) is the main source of shared object verification. solib_present() is called after this first verification step fails. Shared objects that are neither shipped nor created as symlinks by the package can be missed.

This subroutine is not exported.

  update_known_solibs
  update_known_solibs;

update_known_solibs() takes no arguments. It uses the "--print-cache" option of ldconfig(1) to generate an array of existent known shared objects, @native_libs. On 64-bit systems, it generates @libs_32 as well, an array with 32-bit shared objects.

The "initialize_*()" subroutines for the additional package tests are called at this time.

The script exits in case of ldcdonfig(1) failure. There is no useful return value.

EXIT CODES
Solibs.pm subroutines can return the following exit codes:

  _ERR_SCRIPT        2   script or module bug
  _ERR_OPENFH        6   failure to open file handles

SEE ALSO
SBO::Lib(3), SBO::Lib::Build(3), SBO::Lib::Download(3), SBO::Lib::Info(3), SBO::Lib::Pkgs(3), SBO::Lib::Readme(3), SBO::Lib::Repo(3), SBO::Lib::Tree(3), SBO::Lib::Util(3), elf(5), ldconfig(1)

In addition to the man page, "https://refspecs.linuxbase.org/elf/gabi4+/" is a helpful resource about the structure of ELF files.

AUTHORS
SBO::Lib was originally written by Jacob Pipkin <jacob.pipkin@icloud.com> with contributions from Luke Williams <xocel@iquidus.org> and Andreas Guldstrand <andreas.guldstrand@gmail.com>.

MAINTAINER
SBO::Lib is maintained by K. Eugene Carlson <kvngncrlsn@gmail.com>.

LICENSE
The sbotools are licensed under the MIT License.

Copyright (C) 2012-2017, Jacob Pipkin, Luke Williams, Andreas Guldstrand.

Copyright (C) 2024-2026, K. Eugene Carlson.

Copyright (C) 2026, K. Eugene Carlson, Jacob Pipkin.