Sample Header Ad - 728x90

Is it possible to use lazy dynamic linking on Linux?

3 votes
1 answer
2375 views
On UNIX, I may use a commandline like: cc -o executable *.o -zlazyload -lsomelib with the result that the libraries listed to the right of -zlazyload are marked with the LAZYLOAD ELF tag in the binary. This may be verified by calling dump -Lv executable and the result contains e.g.: **** DYNAMIC SECTION INFORMATION **** .dynamic: [INDEX] Tag Value POSFLAG_1 LAZYLOAD NEEDED libsecdb.so.1 In this case, libsecdb is not loaded at the startup time of the executable, but delayed to the time, when the first function from libsecdb is called. This trick may be used to keep the incore representation of the executable smaller if it does not use all features. Is there a way to achive the same on Linux? The GNU linker seems to have a flag -zlazy, but my experience is that this is without effect. The background for this question is that on Solaris, it is simple to link the current Bourne Shell (bosh) using lazy linking and this results in a shell that is nearly as small as dash when executing shell scripts, but that is still faster than dash. The shared libraries for the interactive history editor are only linked if the shell is used in interactive mode.
Asked by schily (19703 rep)
Nov 21, 2020, 08:16 PM
Last activity: Apr 6, 2025, 12:14 AM