1

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
[1]     POSFLAG_1       LAZYLOAD
[2]     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.

6
  • How are you testing if -zlazy works in Linux? – Eduardo Trápani Nov 21 '20 at 22:54
  • E.g. by linking bosh this way on Linux and calling bosh -c 'pmap $$;:' and comparing the result with the result from Solaris. – schily Nov 21 '20 at 23:21
  • @schily. UNIX is a brand, Unix is an operating system. – fpmurphy Nov 22 '20 at 2:53
  • @fpmurphy The original tests have been done on a UNIX certified platform. Linux is not certified. – schily Nov 22 '20 at 13:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.