Skip to content
Snippets Groups Projects

Add inspect-library helper

Merged Ludovico de Nittis requested to merge wip/denittis/inspect-library into master

This is the WIP for the "Executable to dlopen and inspect a library" of T15426.

This is an output example of the current version:

$ ./x86_64-linux-gnu-inspect-library libzvbi.so
{
  "libzvbi.so": {
    "path": "/usr/lib",
    "dependencies": [
      "/usr/lib/libzvbi.so",
      "/usr/lib/libm.so.6",
      "/usr/lib/libpng16.so.16",
      "/usr/lib/libz.so.1"
    ]
  }
}

The next thing to do that is still missing is to take a list of (version, symbol) pairs as input.

Edited by Ludovico de Nittis

Merge request reports

Pipeline #1283 passed

Pipeline passed for 6c25a7e8 on wip/denittis/inspect-library

Approval is optional

Merged by Ludovico de NittisLudovico de Nittis 5 years ago (Jul 26, 2019 12:28pm UTC)

Merge details

  • Changes merged into master with 00d5cd33.
  • Deleted the source branch.

Pipeline #1285 passed

Pipeline passed for 00d5cd33 on master

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
    • Resolved by Simon McVittie

      For examples of use, please use the SONAME of a library, which is usually something like libzvbi.so.0, rather than the bare name libzvbi.so.

      I don't know how much shared library background you have, so my apologies if this all seems very obvious - but you will need to understand how ELF shared libraries work if you are working on the Steam Runtime, so here is a brief summary in case you need it. The way this normally works is:

      • The real physical file implementing the shared library is for example libzvbi.so.0.13.2.
      • The DT_SONAME ELF header is written into the library at link time, and identifies a backwards-compatible ABI family for the library (the SONAME), for example libzvbi.so.0 which is compatible with all earlier versions of libzvbi.so.0
      • The symlink libzvbi.so is for the linker ld, and doesn't normally exist on end-user systems, only on developer systems. When you link with -lzvbi, the linker follows the libzvbi.so symlink, reads the DT_SONAME, and puts a reference to it in the executable or dependent library (a DT_NEEDED ELF header).
      • There is a symlink whose name matches the SONAME. This is for the runtime linker ld.so. When an executable or a dependent library is loaded, the runtime linker reads its DT_NEEDED headers and loads libraries from the search path, using the name in the DT_NEEDED header as a filename.
      • You can have libzvbi.so.0 and libzvbi.so.1 installed in parallel, and they will usually work OK to run programs (a more realistic example is libjpeg.so.62 and libjpeg.so.8, which genuinely do both exist in the Steam Runtime).
      • You cannot have libzvbi.so point to both versions at the same time: you have to choose one. The one you chose will be used for -lzvbi. A realistic example is that in the Steam Runtime SDK, libjpeg.so points to libjpeg.so.8.0.2, which has DT_SONAME = libjpeg.so.8, so linking with -ljpeg gives you a dependency on libjpeg.so.8.
  • added 1 commit

    • df532d37 - Add symbols checking to inspect-library

    Compare with previous version

  • Simon McVittie
  • added 4 commits

    • 51088317 - Remove glib dependency from inspect-library
    • 59ca4541 - Use RTLD_DI_LINKMAP instead of RTLD_DI_ORIGIN for inspect-library
    • e4b8c40a - List all library dependencies by moving "handle" at the beginning
    • 7dfa66c6 - Use RTLD_NOW instead of RTLD_LAZY

    Compare with previous version

  • added 8 commits

    • 57b211ac - Add inspect-library helper
    • 24aed92e - Close the opened handle in inspect-library
    • c0e982b1 - Add symbols checking to inspect-library
    • 2012bcb9 - Remove glib dependency from inspect-library
    • 16a5a505 - Use RTLD_DI_LINKMAP instead of RTLD_DI_ORIGIN for inspect-library
    • 0a46f4d4 - List all library dependencies by moving "handle" at the beginning
    • b407d8ef - Use RTLD_NOW instead of RTLD_LAZY
    • 92371b53 - Read symbols list from a text file

    Compare with previous version

  • Simon McVittie resolved all discussions

    resolved all discussions

  • Simon McVittie
  • added 1 commit

    • 19c9366c - Avoid printing the library itself in the list of dependencies

    Compare with previous version

  • added 2 commits

    • 07e74ad4 - Move libdl to the root meson.build file
    • de71c2cf - Add double quotes and backslashes handling in inspect-library

    Compare with previous version

  • Simon McVittie
  • added 1 commit

    • f44dada9 - Apply suggestion to helpers/inspect-library.c

    Compare with previous version

  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Please register or sign in to reply
    Loading