landlock_restrict_self.2: tfix
[man-pages.git] / man2 / uselib.2
blobdc81f22ec60512b5d93873ba0c7e26ea6888c032
1 .\" Copyright (c) 1992 Drew Eckhardt (drew@cs.colorado.edu), March 28, 1992
2 .\"
3 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
4 .\"
5 .\" Modified by Michael Haardt <michael@moria.de>
6 .\" Modified 1993-07-24 by Rik Faith <faith@cs.unc.edu>
7 .\" Modified 1996-10-22 by Eric S. Raymond <esr@thyrsus.com>
8 .\" Modified 2004-06-23 by Michael Kerrisk <mtk.manpages@gmail.com>
9 .\" Modified 2005-01-09 by aeb
10 .\"
11 .TH USELIB 2 2021-03-22 "Linux" "Linux Programmer's Manual"
12 .SH NAME
13 uselib \- load shared library
14 .SH SYNOPSIS
15 .nf
16 .B #include <unistd.h>
17 .PP
18 .BI "int uselib(const char *" library );
19 .fi
20 .PP
21 .IR Note :
22 No declaration of this system call is provided in glibc headers; see NOTES.
23 .SH DESCRIPTION
24 The system call
25 .BR uselib ()
26 serves to load
27 a shared library to be used by the calling process.
28 It is given a pathname.
29 The address where to load is found
30 in the library itself.
31 The library can have any recognized
32 binary format.
33 .SH RETURN VALUE
34 On success, zero is returned.
35 On error, \-1 is returned, and
36 .I errno
37 is set to indicate the error.
38 .SH ERRORS
39 In addition to all of the error codes returned by
40 .BR open (2)
41 and
42 .BR mmap (2),
43 the following may also be returned:
44 .TP
45 .B EACCES
46 The library specified by
47 .I library
48 does not have read or execute permission, or the caller does not have
49 search permission for one of the directories in the path prefix.
50 (See also
51 .BR path_resolution (7).)
52 .TP
53 .B ENFILE
54 The system-wide limit on the total number of open files has been reached.
55 .TP
56 .B ENOEXEC
57 The file specified by
58 .I library
59 is not an executable of a known type;
60 for example, it does not have the correct magic numbers.
61 .SH STANDARDS
62 .BR uselib ()
63 is Linux-specific, and should not be used in programs
64 intended to be portable.
65 .SH NOTES
66 This obsolete system call is not supported by glibc.
67 No declaration is provided in glibc headers, but, through a quirk of history,
68 glibc versions before 2.23 did export an ABI for this system call.
69 Therefore, in order to employ this system call,
70 it was sufficient to manually declare the interface in your code;
71 alternatively, you could invoke the system call using
72 .BR syscall (2).
73 .PP
74 In ancient libc versions (before glibc 2.0),
75 .BR uselib ()
76 was used to load
77 the shared libraries with names found in an array of names
78 in the binary.
79 .\" .PP
80 .\" .\" libc 4.3.1f - changelog 1993-03-02
81 .\" Since libc 4.3.2, startup code tries to prefix these names
82 .\" with "/usr/lib", "/lib" and "" before giving up.
83 .\" .\" libc 4.3.4 - changelog 1993-04-21
84 .\" In libc 4.3.4 and later these names are looked for in the directories
85 .\" found in
86 .\" .BR LD_LIBRARY_PATH ,
87 .\" and if not found there,
88 .\" prefixes "/usr/lib", "/lib" and "/" are tried.
89 .\" .PP
90 .\" From libc 4.4.4 on only the library "/lib/ld.so" is loaded,
91 .\" so that this dynamic library can load the remaining libraries needed
92 .\" (again using this call).
93 .\" This is also the state of affairs in libc5.
94 .\" .PP
95 .\" glibc2 does not use this call.
96 .PP
97 Since Linux 3.15,
98 .\" commit 69369a7003735d0d8ef22097e27a55a8bad9557a
99 this system call is available only when the kernel is configured with the
100 .B CONFIG_USELIB
101 option.
102 .SH SEE ALSO
103 .BR ar (1),
104 .BR gcc (1),
105 .BR ld (1),
106 .BR ldd (1),
107 .BR mmap (2),
108 .BR open (2),
109 .BR dlopen (3),
110 .BR capabilities (7),
111 .BR ld.so (8)