
db layout 0.3.0

packages 1 : n files 1 : n  findable links
findable link in a ldsearchpath

package:
id
name

file:
package.id
filename, elfname, arch

ldtype_id
id
type (rpath, trusted, LD_LIBRARY_PATH, ld.so,conf)

ldpath:
id
ldtype_id
dir

findalbe
id
file.id
ldpath.id


a lib might have links in multiple dirs, 

after adding everything to file
get those that are not findable per default, 
and add links ...
check where they exist, first hit winns, 

or , streight go through all ld dirs on the system and check the links



one table with linker search path, and add the type for it

LD_LIBRARY_PATH can be added dynamically if wanted, and union selected,
it needs just to be as a lddir_type available

the types shall come from here:

The (colon-separated) paths in the DT_RPATH dynamic section attribute of the binary if present and the DT_RUNPATH attribute does not exist.
The (colon-separated) paths in the environment variable LD_LIBRARY_PATH, unless the executable is a setuid/setgid binary, in which case it is ignored. LD_LIBRARY_PATH can be overridden by calling the dynamic linker with the option --library-path (e.g. /lib/ld-linux.so.2 --library-path $HOME/mylibs myprogram).
The (colon-separated) paths in the DT_RUNPATH dynamic section attribute of the binary if present.
Lookup based on the ldconfig cache file (often located at /etc/ld.so.cache) which contains a compiled list of candidate libraries previously found in the augmented library path (set by /etc/ld.so.conf). If, however, the binary was linked with the -z nodefaultlib linker option, libraries in the default library paths are skipped.
In the trusted default path /lib, and then /usr/lib. If the binary was linked with the -z nodefaultlib linker option, this step is skipped.


http://amir.rachum.com/blog/2016/09/17/shared-libraries/
For security reasons, when running an executable with elevated privileges (such as setuid, setgid, special capabilities, etc.), the search path list is different than normal: LD_LIBRARY_PATH is ignored, as well as any path in rpath or runpath that contains $ORIGIN.

An important behavior to note here is that, for these kind of applications, ldd lies to our face:

this is something I could utilize,
https://accu.org/index.php/journals/1372
and maybe make a talk, about unix linker


this seems to be good
https://www.lurklurk.org/linkers/linkers.html


indexing:
it does not work without going throuhg the dirs,
need links from there to other locations, these files are currently not in the whoneed
and if I do a requires query without using the filesystem, just the db, this will also be lost


maybe add some analytics, files in fs but not in db, this could be informative...


did you know RTLD-AUDIT
http://man7.org/linux/man-pages/man7/rtld-audit.7.html


http://man7.org/linux/man-pages/man1/sprof.1.html