[2/5] AArch64: Improve A64FX memset for large sizes
[glibc.git] / include / dlfcn.h
bloba4c283728f94deb4b8d0f30303fe8367bce5f286
1 #ifndef _DLFCN_H
2 #include <dlfcn/dlfcn.h>
3 #ifndef _ISOMAC
4 #include <link.h> /* For ElfW. */
5 #include <stdbool.h>
7 /* Internally used flag. */
8 #define __RTLD_DLOPEN 0x80000000
9 #define __RTLD_SPROF 0x40000000
10 #define __RTLD_OPENEXEC 0x20000000
11 #define __RTLD_CALLMAP 0x10000000
12 #define __RTLD_AUDIT 0x08000000
13 #define __RTLD_SECURE 0x04000000 /* Apply additional security checks. */
14 #define __RTLD_NOIFUNC 0x02000000 /* Suppress calling ifunc functions. */
16 #define __LM_ID_CALLER -2
18 /* These variables are defined and initialized in the startup code. */
19 extern int __libc_argc attribute_hidden;
20 extern char **__libc_argv attribute_hidden;
22 /* Now define the internal interfaces. */
24 /* Use RTLD_NOW here because:
25 1. In pthread_cancel_init we want to use RTLD_NOW to reduce the stack usage
26 of future cancellation operations, particularly when the target thread
27 is running with a small stack. Likewise for consistency we do the same
28 thing in __libgcc_s_init. RTLD_NOW will rarely make a difference for
29 __libgcc_s_init because unwinding is already in progress, so libgcc_s.so
30 has already been loaded if its unwinder is used (Bug 22636).
31 2. It allows us to provide robust fallback code at dlopen time for
32 incorrectly configured systems that mix old libnss_* modules
33 with newly installed libraries e.g. old libnss_dns.so.2 with new
34 libresolv.so.2. Using RTLD_LAZY here causes a failure at the
35 time the symbol is called and at that point it is much harder to
36 safely return an error (Bug 22766).
38 The use of RTLD_NOW also impacts gconv module loading, backtracing
39 (where the unwinder form libgcc_s.so is used), and IDNA functions
40 (which load libidn2), all of which load their respective DSOs on
41 demand, and so should not impact program startup. That is to say
42 that the DSOs are loaded as part of an API call and therefore we
43 will be calling that family of API functions shortly so RTLD_NOW or
44 RTLD_LAZY is not a big difference in performance, but RTLD_NOW has
45 better error handling semantics for the library. */
46 #define __libc_dlopen(name) \
47 __libc_dlopen_mode (name, RTLD_NOW | __RTLD_DLOPEN)
48 extern void *__libc_dlopen_mode (const char *__name, int __mode)
49 attribute_hidden;
50 extern void *__libc_dlsym (void *__map, const char *__name)
51 attribute_hidden;
52 extern void *__libc_dlvsym (void *map, const char *name, const char *version)
53 attribute_hidden;
54 extern int __libc_dlclose (void *__map)
55 attribute_hidden;
57 /* Locate shared object containing the given address. */
58 #ifdef ElfW
59 extern int _dl_addr (const void *address, Dl_info *info,
60 struct link_map **mapp, const ElfW(Sym) **symbolp)
61 attribute_hidden;
62 #endif
64 struct link_map;
66 /* Close an object previously opened by _dl_open. */
67 extern void _dl_close (void *map) attribute_hidden;
68 /* Same as above, but without locking and safety checks for user
69 provided map arguments. */
70 extern void _dl_close_worker (struct link_map *map, bool force)
71 attribute_hidden;
73 /* Look up NAME in shared object HANDLE (which may be RTLD_DEFAULT or
74 RTLD_NEXT). WHO is the calling function, for RTLD_NEXT. Returns
75 the symbol value, which may be NULL. */
76 extern void *_dl_sym (void *handle, const char *name, void *who)
77 attribute_hidden;
79 /* Look up version VERSION of symbol NAME in shared object HANDLE
80 (which may be RTLD_DEFAULT or RTLD_NEXT). WHO is the calling
81 function, for RTLD_NEXT. Returns the symbol value, which may be
82 NULL. */
83 extern void *_dl_vsym (void *handle, const char *name, const char *version,
84 void *who) attribute_hidden;
86 /* Helper function for <dlfcn.h> functions. Runs the OPERATE function via
87 _dl_catch_error. Returns zero for success, nonzero for failure; and
88 arranges for `dlerror' to return the error details.
89 ARGS is passed as argument to OPERATE. */
90 extern int _dlerror_run (void (*operate) (void *), void *args) attribute_hidden;
92 /* This structure is used to make the outer (statically linked)
93 implementation of dlopen and related functions to the inner libc
94 after static dlopen, via the GLRO (dl_dlfcn_hook) pointer. */
95 struct dlfcn_hook
97 /* Public interfaces. */
98 void *(*dlopen) (const char *file, int mode, void *dl_caller);
99 int (*dlclose) (void *handle);
100 void *(*dlsym) (void *handle, const char *name, void *dl_caller);
101 void *(*dlvsym) (void *handle, const char *name, const char *version,
102 void *dl_caller);
103 char *(*dlerror) (void);
104 int (*dladdr) (const void *address, Dl_info *info);
105 int (*dladdr1) (const void *address, Dl_info *info,
106 void **extra_info, int flags);
107 int (*dlinfo) (void *handle, int request, void *arg);
108 void *(*dlmopen) (Lmid_t nsid, const char *file, int mode, void *dl_caller);
110 /* Internal interfaces. */
111 void* (*libc_dlopen_mode) (const char *__name, int __mode);
112 void* (*libc_dlsym) (void *map, const char *name);
113 void* (*libc_dlvsym) (void *map, const char *name, const char *version);
114 int (*libc_dlclose) (void *map);
117 /* Note: These prototypes are for initializing _dlfcn_hook in static
118 builds; see __rtld_static_init. Internal calls in glibc should use
119 the __libc_dl* functions defined in elf/dl-libc.c instead. */
121 extern void *__dlopen (const char *file, int mode, void *caller);
122 extern void *__dlmopen (Lmid_t nsid, const char *file, int mode,
123 void *dl_caller);
124 extern int __dlclose (void *handle);
125 extern void *__dlsym (void *handle, const char *name, void *dl_caller);
126 extern void *__dlvsym (void *handle, const char *name, const char *version,
127 void *dl_caller);
128 extern int __dladdr (const void *address, Dl_info *info);
129 extern int __dladdr1 (const void *address, Dl_info *info,
130 void **extra_info, int flags);
131 extern int __dlinfo (void *handle, int request, void *arg);
132 extern char *__dlerror (void);
134 #endif
135 #endif