Skip to content

Get uninstalled libraries from environment instead of introspecting ELF

Simon McVittie requested to merge wip/smcv/issue6877 into main
  • Get uninstalled libraries from environment in preference to ELF headers

    Introspecting the dynamic headers is low-level and full of implementation details.

    It seems that gnome-shell was assuming the address of the string table is given by taking the DT_STRTAB dynamic symbol table's value (d_un.d_val) and casting it to an absolute pointer. However, in some environments (apparently including Debian mips64el) the DT_STRTAB dynamic symbol table's d_un.d_val can be merely an offset relative to the base address of the executable in memory. The base address would have to be parsed from a different ELF header, which as far as I know is not part of _DYNAMIC.

    Rather than trying to look up the Shell executable's base address using dlinfo() or similar, during unit testing it seems easier to pass in the uninstalled library search path in the environment, along with other uninstalled paths that we are going to need anyway.

    The reason given for not using GI_TYPELIB_PATH in commit 9bc89b82 "main: Prepend RPATH or RUNPATH paths to gir search paths" was that g_irepository_prepend_library_path() takes precedence, but we can easily define our own environment variable that takes even higher precedence. If it's set, we might as well also bypass the PKGLIBDIR, since while running uninstalled we only want to use the uninstalled libraries.

    When not running unit tests, it's desirable to make ./build/src/gnome-shell something you can run directly, so continue to parse the ELF headers - but only on x86_64, where we're reasonably confident that it works and any regressions with a newer glibc will be noticed promptly.

    Resolves: #6877 (closed)
    Bug-Debian: https://bugs.debian.org/1042980

Edited by Simon McVittie

Merge request reports