K42 provides a library called exec.so. This library provides the OS functionality that K42 expects to be implemented within a process. It also provides the system-call transfer-table and the functions it points to. Exec.so maintains data such as stateful I/O interfaces that implement select and poll, and must be initialized before any Linux code executes. This early initialization needs to occur so that we can provide support for system calls made by the dynamic linker and glibc.
A K42 process can be created using native K42 facilities (not fork/exec). This creation occurs by constructing the objects that represent that new process in the parent. During this construction, the parent loads exec.so into this new or child process. It also loads information containing what executable that child process should run. The new child process starts running in exec.so and loads the appropriate Linux executable, and if necessary, the dynamic linker. As part of its initialization, exec.so creates and initializes the system-call transfer-table, and then jumps to the appropriate entry point of the Linux application. The Linux application is now able to make system calls that are handled by the code in exec.so via the system-call transfer-table, or by trap-reflection, which also uses the table. This mechanism is established without any symbol dependencies between the Linux application and exec.so.
We must also provide a mechanism to allow applications to access K42 library interfaces directly. However, we cannot simply allow the dynamic linker to load a new image of exec.so because the existing K42 code in exec.so contains important state information. Instead, the library image that the dynamic linker loads contains specially modified ELF headers that direct the dynamic linker to look for K42 library code, data, and symbol information in the location where exec.so has been already loaded. In a 64-bit address space it is easy to always load exec.so at the same location allowing us to avoid the need to relocate exec.so at run-time.