Add inspect-library helper
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
Activity
- Resolved by Ludovico de Nittis
- Resolved by Ludovico de Nittis
- Resolved by Ludovico de Nittis
- Resolved by Ludovico de Nittis
- 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 namelibzvbi.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 examplelibzvbi.so.0
which is compatible with all earlier versions oflibzvbi.so.0
- The symlink
libzvbi.so
is for the linkerld
, and doesn't normally exist on end-user systems, only on developer systems. When you link with-lzvbi
, the linker follows thelibzvbi.so
symlink, reads theDT_SONAME
, and puts a reference to it in the executable or dependent library (aDT_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 itsDT_NEEDED
headers and loads libraries from the search path, using the name in theDT_NEEDED
header as a filename. - You can have
libzvbi.so.0
andlibzvbi.so.1
installed in parallel, and they will usually work OK to run programs (a more realistic example islibjpeg.so.62
andlibjpeg.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 tolibjpeg.so.8.0.2
, which hasDT_SONAME = libjpeg.so.8
, so linking with-ljpeg
gives you a dependency onlibjpeg.so.8
.
- The real physical file implementing the shared library is for example
- Resolved by Ludovico de Nittis
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
Toggle commit list- Resolved by Simon McVittie
- Resolved by Ludovico de Nittis
- Resolved by Ludovico de Nittis
added 1 commit
- 19c9366c - Avoid printing the library itself in the list of dependencies
- Resolved by Ludovico de Nittis
- Resolved by Ludovico de Nittis
- Resolved by Simon McVittie
added 1 commit
- f44dada9 - Apply suggestion to helpers/inspect-library.c
Please register or sign in to reply