prelink(8)
๐ prelink(8) ๐
System Manager's Manual โ yep, section 8, we're in full sysadmin main-character territory now โจ
๐ธ NAME ๐ธ
prelink โ prelink ELF shared libraries and binaries to speed up startup time
๐ SYNOPSIS ๐
prelink [OPTION...] [FILES]
๐ฆ DESCRIPTION ๐ฆ
okay so bestie, listen. prelink is a program that goes into your ELF shared libraries and your ELF dynamically linked binaries and โจmodifiesโจ them so that the dynamic linker spends way less time doing relocations at startup. It's giving "make the computer wake up faster" and honestly? It ate. ๐
And because there are fewer relocations to do, the run-time memory consumption goes down too โ especially the number of unshareable pages. Iconic. ๐ซถ
the prelinking information is only used at startup if none of the dependent libraries have changed since prelinking. If something did change, the programs just get relocated normally, no drama. ๐
So here's the whole vibe of how it works, step by step:
prelinkfirst collects the ELF binaries it's supposed to prelink, plus all the ELF shared libraries they depend on.- Then it assigns a unique virtual address space slot to each library, and relinks the shared library to that base address.
- When the dynamic linker tries to load such a library, unless that virtual address space slot is already occupied, it maps the library into the given slot. (slot taken = sorry bestie, you go elsewhere ๐)
- After that's done,
prelinkโ with the help of the dynamic linker โ resolves all the relocations in the binary or library against its dependent libraries, and stores those relocations into the ELF object. - It also stores a list of all dependent libraries together with their checksums into the binary or library.
- For binaries specifically, it also computes a list of conflicts (these are relocations that resolve differently in the binary's symbol search scope than in the smaller search scope in which the dependent library was resolved) and stores that list into a special ELF section.
Then at runtime, the dynamic linker first checks whether all the dependent libraries were successfully mapped into their designated address space slots, and whether they have not changed since the prelinking was done. If all the checks pass, the dynamic linker just replays the list of conflicts โ which is usually significantly shorter than the total number of relocations โ instead of relocating each library. efficiency queen behavior ๐
โจ OPTIONS โจ
-v,--verboseโ Verbose mode, bestie. Prints the virtual address slots assigned to libraries, and tells you what binary or library is currently being prelinked. It's like a little live commentary track. ๐๏ธ-n,--dry-runโ Don't actually prelink anything! Just collect the binaries/libraries, assign them addresses, and with-vprint what would be prelinked. Manifesting prelinking without doing prelinking. ๐ฎ-a,--allโ Prelink all binaries and dependent libraries found in the directory hierarchies specified in/etc/prelink.conf. Normally (i.e. without this) only the binaries specified on the command line and their dependent libraries get prelinked.-m,--conserve-memoryโ When assigning addresses to libraries, allow overlap of address space slots, provided that the two libraries are not present together in any of the binaries or libraries. This means a smaller virtual address space range gets used for libraries. BUT โ the trade-off is real: ifprelinksees a binary during incremental prelinking that puts together two libraries which weren't present together in any other binary and were given the same virtual address space slots, then that binary cannot be prelinked. ๐ญ Without this option, each library gets its own unique virtual address space slot, no sharing.-R,--randomโ When assigning addresses to libraries, start with a random address within the architecture-dependent virtual address space range. This can make some buffer overflow attacks slightly harder to exploit, because libraries are not present at the same addresses across different machines. Normally, assigning virtual addresses starts at the bottom of the architecture-dependent range.-r,--reloc-only=ADDRESSโ Instead of prelinking, just relink the given shared libraries to the specified base address.-N,--no-update-cacheโ Don't save the cache file after prelinking. Normally the list of libraries (and, with-m, binaries too) is stored into the/etc/prelink.cachefile together with their given address space slots and dependencies, so the cache can be used during incremental prelinking (which is prelinking without the-aoption).-c,--config-file=CONFIGโ Specify an alternate config file instead of the default/etc/prelink.conf.-C,--cache-file=CACHEโ Specify an alternate cache file instead of the default/etc/prelink.cache.-f,--forceโ Force re-prelinking even for already prelinked objects whose dependencies are unchanged. This option causes new virtual address space slots to be assigned to all libraries. Normally, only binaries or libraries that are either not prelinked yet, or whose dependencies have changed, get prelinked.-q,--quickโ Runprelinkin quick mode. This mode checks just themtimeandctimetimestamps of libraries and binaries stored in the cache file. If they are unchanged from the lastprelinkrun, it is assumed that the library in question did not change โ without parsing or verifying its ELF headers. Speedrun strats. โก-p,--print-cacheโ Print the contents of the cache file (normally/etc/prelink.cache) and exit.--dynamic-linker=LDSOโ Specify an alternate dynamic linker instead of the default.--ld-library-path=PATHโ Specify a specialLD_LIBRARY_PATHto be used whenprelinkqueries the dynamic linker about symbol resolution details.--layout-page-size=SIZEโ Layout the start of libraries at the given boundary.--libs-onlyโ Only prelink ELF shared libraries, don't prelink any binaries.-h,--dereferenceโ When processing command line directory arguments, follow symbolic links when walking directory hierarchies. ๐-l,--one-file-systemโ When processing command line directory arguments, limit the directory tree walk to a single file system.-T,--timestamp-outputโ Prefix output with timestamps. ๐-u,--undoโ Revert binaries and libraries to their original content, from before they were prelinked. Without the-aoption, this causes only the binaries and libraries specified on the command line to be reverted to their original state (and e.g. not their dependencies). If used together with the-aoption, all binaries and libraries from the command line, all their dependencies, all binaries found in directories specified on the command line and in the config file, and all their dependencies are undone. It's the ctrl+Z of prelinking. ๐-y,--verifyโ Verifies a prelinked binary or library. This option can be used only on a single binary or library. It first applies an--undooperation on the file, then prelinks just that file again and compares this with the original file. If both are identical, it prints the file after the--undooperation on standard output and exits with zero status. Otherwise it exits with error status. So: if the--verifyoperation returns zero exit status and its standard output is equal to the content of the binary or library before prelinking, you can be sure that nobody modified the binaries or libraries after prelinking. Similarly with message digests and checksums โ unless you trigger the improbable case of a modified file and the original file having the same digest or checksum. ๐-y,--md5โ This is similar to the--verifyoption, except instead of outputting the content of the binary or library before prelinking to standard output, the MD5 digest is printed. Seemd5sum(1).-y,--shaโ This is similar to the--verifyoption, except instead of outputting the content of the binary or library before prelinking to standard output, the SHA1 digest is printed. Seesha1sum(1).--exec-shield,--no-exec-shieldโ On IA-32, if the kernel supports Exec-Shield,prelinkattempts to lay libraries out similarly to how the kernel places them (i.e. if possible below the binary, most widely used into the ASCII armor zone). These switches allow overridingprelink's detection of whether Exec-Shield is supported or not. ๐ก๏ธ-b,--black-list=PATHโ This option allows blacklisting certain paths, libraries or binaries.Prelinkwill not touch them during prelinking. ๐ซ-o,--undo-output=FILEโ When performing an--undooperation, don't overwrite the prelinked binary or library with its original content (before it was prelinked), but save that into the specified file.-V,--versionโ Print version and exit.-?,--helpโ Print short help and exit.--usageโ Print short usage message.
๐ ARGUMENTS ๐
Command-line arguments should be either directory hierarchies (in which case the -l and -h options apply), or particular ELF binaries or shared libraries.
Specifying a shared library explicitly on the command line causes it to be prelinked even if no binary is linked against it. Otherwise, binaries are collected together and only the libraries they depend on are prelinked with them.
๐ซ EXAMPLES ๐ซ
# /usr/sbin/prelink -avmR
prelinks all binaries found in directories specified in /etc/prelink.conf and all their dependent libraries, assigning libraries unique virtual address space slots only if they ever appear together, and starts assigning libraries at a random address. ๐ฒ
# /usr/sbin/prelink -vm ~/bin/progx
prelinks ~/bin/progx program and all its dependent libraries (unless they were prelinked already e.g. during a prelink -a invocation).
# /usr/sbin/prelink -au
reverts all binaries and libraries to their original content.
# /usr/sbin/prelink -y /bin/prelinked_prog > /tmp/original_prog;
echo $?
verifies whether /bin/prelinked_prog is unchanged.
๐พ FILES ๐พ
/etc/prelink.cacheโ okay so this is a binary file bestie, and it contains a list of prelinked libraries and/or binaries together with their assigned virtual address space slots and dependencies. Wanna see what's actually in there? Run/usr/sbin/prelink -pand it will show you. โจ/etc/prelink.confโ this is the config file with a list of directory hierarchies that contain ELF shared libraries or binaries which should be prelinked. It gets used in-amode to find binaries which should be prelinked, and also, no matter whether-ais given or not, to limit which dependent shared libraries should be prelinked. Ifprelinkfinds a dependent library of some binary or other library which is not present in any of the directories specified either in/etc/prelink.confor on the command line, then it cannot be prelinked. No cap, it just can't. ๐ญ
Each line of the config file should be either:
- a comment starting with
# - a directory name
- or a blacklist specification
Directory names can be prefixed by the -l switch, meaning the tree walk of the given directory is only limited to one file system; or the -h switch, meaning the tree walk of the given directory follows symbolic links. Slay, tree-walk options. ๐ฆ
A blacklist specification should be prefixed by -b, and optionally also -l or -h if needed. A blacklist entry can be either:
- an absolute directory name (in that case all files in that directory hierarchy are ignored by the prelinker);
- an absolute filename (then that particular library or binary is skipped);
- or a glob pattern without a
/character in it (then all files matching that glob in any directory are ignored).
So yeah, that's the whole blacklist vibe. Iconic. ๐
๐ SEE ALSO ๐
Besties to check out: ldd(1), ld.so(8). Go read those too, iykyk. ๐
๐ BUGS ๐
prelinkSome architectures, includingIA-64andHPPA, are not yet supported.
So if you're on one of those, it's giving not-yet-supported energy, bestie. Not every architecture gets an invite to the prelink party yet. ๐
โ๏ธ AUTHORS โ๏ธ
Jakub Jelinek <jakub@redhat.com>. The icon, the legend, the author. ๐
๐ That's the whole prelink(8) page, bestie. This one is stamped 19 July 2013, and it's the prelink(8) manual. Now go forth and prelink responsibly. Periodt. ๐
๐ฆ where this page comes from
- ubuntu jammy: prelink 0.0.20131005-1.1 ยท GPL-2.0-or-later
- ubuntu noble: prelink 0.0.20131005-1.1ubuntu1 ยท GPL-2.0-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms