uselib(2)

๐Ÿ’– uselib โ€” load shared library ๐Ÿ’–

okay bestie, gather round, because we're talking about uselib(2), a genuine fossil of a system call from the System Calls Manual. it loads a shared library. that's the whole job. it's giving "vintage", it's giving "why is this still in the kernel", and yes, it is deprecated. let's get into it ๐Ÿ’…


โœจ SYNOPSIS โœจ

#include <unistd.h>

[[deprecated]] int uselib(const char *library);

see that [[deprecated]] right there? that's the compiler side-eyeing you. respect it.


๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

okay so here's the tea. the system call uselib() serves to load a shared library to be used by the calling process. that's its whole personality.

you hand it a pathname โ€” that's your library. and the address of where to actually load it? not your problem, babes. the address where to load is found in the library itself. iconic behaviour honestly.

also, the library can have any recognized binary format. so whatever format the system recognizes, it's valid. no gatekeeping ๐ŸŒˆ


๐ŸŽ€ RETURN VALUE ๐ŸŽ€

  • on success, zero is returned. slay.
  • on error, -1 is returned, and errno is set to indicate the error. yeah, the classic -1 + errno combo, we've all been there ๐Ÿ˜ญ

๐Ÿ’€ ERRORS ๐Ÿ’€

so in addition to all of the error codes returned by open(2) and mmap(2) (yes, all of them, go read those pages too, i'm not doing your homework for you), the following may also be returned:

  • EACCES โ€” the library specified by library does not have read or execute permission, or the caller does not have search permission for one of the directories in the path prefix. (see also path_resolution(7).) basically the vibes were denied at the door ๐Ÿšซ
  • ENFILE โ€” the system-wide limit on the total number of open files has been reached. too many files open, the whole system is overstimulated, no more for anyone ๐Ÿ™ˆ
  • ENOEXEC โ€” the file specified by library is not an executable of a known type; for example, it does not have the correct magic numbers. the โœจmagicโœจ is wrong. sorry bestie, that's not a real executable ๐Ÿ”ฎ

โญ STANDARDS โญ

Linux. that's it. that's the standard. Linux ๐Ÿง


๐Ÿ‘‘ HISTORY ๐Ÿ‘‘

okay this is the part where it gets really good, because the lore is unhinged:

  • this obsolete system call is not supported by glibc. no declaration is provided in glibc headers. BUT โ€” and this is the quirk of history i'm obsessed with โ€” glibc before glibc 2.23 did export an ABI for this system call. the way that glibc just quietly kept an ABI lying around?? ๐Ÿ’€
  • therefore, in order to employ this system call, it was sufficient to manually declare the interface in your code; alternatively, you could invoke the system call using syscall(2). DIY era fr fr.
  • in ancient libc versions (before glibc 2.0), uselib() was used to load the shared libraries with names found in an array of names in the binary. ancient. prehistoric. archaeological ๐Ÿฆ•
  • since Linux 3.15, this system call is available only when the kernel is configured with the CONFIG_USELIB option. so if your kernel didn't check that box, this call simply does not exist for you. no cap.

๐ŸŒธ SEE ALSO ๐ŸŒธ

go read those, bestie, you'll be so smart ๐Ÿซถ


and that's the whole page!! this edition of the documentation came from Linux man-pages 6.20, dated 2026-02-08, and it's been an absolute pleasure doing fossil restoration with you ๐Ÿ’–โœจ๐ŸŽ€ mwah, go write some code, you main character ๐Ÿ‘‘๐ŸŒˆ๐Ÿ’œ

๐Ÿ“ฆ where this page comes from
  • arch rolling: man-pages 6.20-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
  • nixpkgs unstable: man-pages 6.20
  • ๐Ÿ“œ the page's license: Linux-man-pages-copyleft
  • ๐Ÿ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms