[midipix] it's all relative: finalizing the midipix ldso logic

writeonce at midipix.org writeonce at midipix.org
Sat Dec 17 04:30:18 UTC 2016

Dear all,

Following a very long thinking process and much discussion on irc,
please find below what could become the final logic of the midipix
dynamic loader (ldso). Before we begin, however, a couple of important

* the midipix ldso logic only pertains to midipix framework applications
(either hosted or free-standing), and bears absolutely no effect on
non-midipix applications spawned by a framework process.
* the midipix ldso logic only pertains the dynamically linked
applications, and accordingly does not preclude the ability to create
zero-dependency, statically-linked applications.

Now to the logic...

For the purpose of the midipix dynamic loader, there exist only TWO
TYPES of framework applications, each of which corresponding to a unique
build-time setting.

TYPE ONE: standalone application:

+ compiler switch: -mldso-standalone-exec[utable]
+ root directory resolution: unless inherited from a parent framework
process, the precess's root directory ('/') shall remain virtual only;
+ LD_LIBRARY_PATH is _always_ ignored
+ dependency libraries marked as 'system' are loaded from the OS's
system directory (aka %system32%)
+ all other dependency libraries are loaded from the application's
directory, and from that directory alone.

TYPE TWO: default application

+ compiler switch: -mldso
+ root directory resolution: the process's root directory ('/') must be
set to a physical file-system directory
+ the framework's dynamic loader, libpsxscl.so, must be found under the
/lib directory
+ dependency libraries marked as 'system' are loaded from the OS's
system directory (aka %system32%)
+ all other dependency libraries are loaded from their respective
+ the loader's library search path adheres to the following logic:
++ LD_LIBRARY_PATH is respected if set
++ application-specific relative library locations may be hard-coded at
build-time via -rpath
++ if a physical configuration file named /etc/ld-midipix-nt{32|64}.path
is present, then read default library locations from that file.
++ if the above physical configuration file is not present, then use
"/lib:/usr/local/lib:/usr/lib" for default library locations.


+ the ldso root directory resolution only applies to TYPE TWO
+ a qualifying loader directory must be named 'lib', and must also
contain a PE framework loader image named 'libpsxscl.so'
+ a qualifying root directory must have a qualifying loader directory as
one of its immediate sub-directories.
+ if the current process is the child of a framework process that has
its physical root directory set, then inherit the parent process's
physical root setting.
+ if the current process is a top-level framework process, then set the
current process's root directory to the first qualifying root directory
found beginning with the parent folder of the folder containing the
current process's executable image, and moving up the directory tree one
parent folder at a time.
+ for the purpose of ldso root directory resolution, a directory may be
considered the parent folder of another folder if and only if both
directories are located on the same user-visible partition of the same
logical device.


More information about the midipix mailing list