Description
Inspiration from Agner Fog: https://agner.org/optimize/blog/read.php?i=833
The well-known method for static linking is used. An option to the linker specifies that certain object files or library files should be re-linkable. The necessary symbol and relocation records are then preserved in the executable file so that the library functions can later be replaced by repeating the link process.
This concept has many advantages:
The executable file is ready to run without any external dependencies. You will never have problems with a missing DLL or a wrong version of a shared object.
An important advantage of static linking is that you don't have to load a large dynamic library containing hundreds of functions when you only need a few of these functions. The re-linking feature combines this advantage with the ability to update or replace a library later or to use a third-party library, which traditionally requires dynamic linking.
If you update a DLL in Windows, you are affecting all programs that use this DLL, even if some programs work better with the old version. With re-linkable libraries, you can update a library in each program separately.
You can update or modify a program without access to the original source code.
The rarely used symbol interposition feature in shared objects is very inefficient because all accesses to public symbols go through global offset tables (GOT) and procedure linkage tables (PLT). These inefficient table lookups are not needed with the relink method
You can have different versions of your functions for different platforms. For example, the same program can have different graphical user interfaces for different environments. The appropriate version can conveniently be linked to the executable program as part of the installation procedure.
You can have specific versions of a critical piece of code optimized for different microprocessor models.
You can reconfigure a program at any time if you update the hardware or operating system.
You are not wasting time on loading and linking dynamic libraries every time a program is loaded.
Modifying or updating an executable program requires administrator privileges, for security reasons.
Is this within Zig's scope to integrate? This would do away with so much suffering surrounding library maintenance and management.