]> git.ipfire.org Git - thirdparty/glibc.git/blame - include/dlfcn.h
Further harden glibc malloc metadata against 1-byte overflows.
[thirdparty/glibc.git] / include / dlfcn.h
CommitLineData
6796bc80 1#ifndef _DLFCN_H
94e365c6 2#include <dlfcn/dlfcn.h>
31341567 3#ifndef _ISOMAC
8dd56993 4#include <link.h> /* For ElfW. */
74780cf6 5#include <stdbool.h>
bdbf022d 6
2f54c82d
UD
7/* Internally used flag. */
8#define __RTLD_DLOPEN 0x80000000
9d0881aa 9#define __RTLD_SPROF 0x40000000
5a4b5076 10#define __RTLD_OPENEXEC 0x20000000
c14e9135 11#define __RTLD_CALLMAP 0x10000000
9dcafc55 12#define __RTLD_AUDIT 0x08000000
8e9f92e9 13#define __RTLD_SECURE 0x04000000 /* Apply additional security checks. */
3a62d00d 14#define __RTLD_NOIFUNC 0x02000000 /* Suppress calling ifunc functions. */
2f54c82d 15
c0f62c56
UD
16#define __LM_ID_CALLER -2
17
9dcafc55
UD
18#ifdef SHARED
19/* Locally stored program arguments. */
20extern int __dlfcn_argc attribute_hidden;
21extern char **__dlfcn_argv attribute_hidden;
22#else
23/* These variables are defined and initialized in the startup code. */
24extern int __libc_argc attribute_hidden;
25extern char **__libc_argv attribute_hidden;
26
27# define __dlfcn_argc __libc_argc
28# define __dlfcn_argv __libc_argv
29#endif
30
31
bdbf022d 32/* Now define the internal interfaces. */
b3fc5f84 33
102070bc
UD
34#define __libc_dlopen(name) \
35 __libc_dlopen_mode (name, RTLD_LAZY | __RTLD_DLOPEN)
a784e502
UD
36extern void *__libc_dlopen_mode (const char *__name, int __mode);
37extern void *__libc_dlsym (void *__map, const char *__name);
aaa8d85c 38extern int __libc_dlclose (void *__map);
9d79e037
UD
39libc_hidden_proto (__libc_dlopen_mode)
40libc_hidden_proto (__libc_dlsym)
41libc_hidden_proto (__libc_dlclose)
94e365c6
UD
42
43/* Locate shared object containing the given address. */
8dd56993
RM
44#ifdef ElfW
45extern int _dl_addr (const void *address, Dl_info *info,
46 struct link_map **mapp, const ElfW(Sym) **symbolp)
94e365c6 47 internal_function;
a20d8dbe 48libc_hidden_proto (_dl_addr)
8dd56993 49#endif
94e365c6 50
965cba04
UD
51struct link_map;
52
94e365c6 53/* Close an object previously opened by _dl_open. */
9dcafc55 54extern void _dl_close (void *map) attribute_hidden;
11bf311e
UD
55/* Same as above, but without locking and safety checks for user
56 provided map arguments. */
02d5e5d9
PK
57extern void _dl_close_worker (struct link_map *map, bool force)
58 attribute_hidden;
94e365c6
UD
59
60/* Look up NAME in shared object HANDLE (which may be RTLD_DEFAULT or
61 RTLD_NEXT). WHO is the calling function, for RTLD_NEXT. Returns
62 the symbol value, which may be NULL. */
63extern void *_dl_sym (void *handle, const char *name, void *who)
b3fc5f84
UD
64 internal_function;
65
94e365c6
UD
66/* Look up version VERSION of symbol NAME in shared object HANDLE
67 (which may be RTLD_DEFAULT or RTLD_NEXT). WHO is the calling
68 function, for RTLD_NEXT. Returns the symbol value, which may be
69 NULL. */
70extern void *_dl_vsym (void *handle, const char *name, const char *version,
71 void *who)
72 internal_function;
8e17ea58 73
94e365c6
UD
74/* Helper function for <dlfcn.h> functions. Runs the OPERATE function via
75 _dl_catch_error. Returns zero for success, nonzero for failure; and
76 arranges for `dlerror' to return the error details.
77 ARGS is passed as argument to OPERATE. */
78extern int _dlerror_run (void (*operate) (void *), void *args)
79 internal_function;
80
5f21997b
UD
81#ifdef SHARED
82# define DL_CALLER_DECL /* Nothing */
83# define DL_CALLER RETURN_ADDRESS (0)
84#else
85# define DL_CALLER_DECL , void *dl_caller
86# define DL_CALLER dl_caller
87#endif
88
89struct dlfcn_hook
90{
91 void *(*dlopen) (const char *file, int mode, void *dl_caller);
92 int (*dlclose) (void *handle);
93 void *(*dlsym) (void *handle, const char *name, void *dl_caller);
94 void *(*dlvsym) (void *handle, const char *name, const char *version,
95 void *dl_caller);
96 char *(*dlerror) (void);
97 int (*dladdr) (const void *address, Dl_info *info);
98 int (*dladdr1) (const void *address, Dl_info *info,
99 void **extra_info, int flags);
100 int (*dlinfo) (void *handle, int request, void *arg, void *dl_caller);
101 void *(*dlmopen) (Lmid_t nsid, const char *file, int mode, void *dl_caller);
102 void *pad[4];
103};
104
105extern struct dlfcn_hook *_dlfcn_hook;
106libdl_hidden_proto (_dlfcn_hook)
107
108extern void *__dlopen (const char *file, int mode DL_CALLER_DECL)
109 attribute_hidden;
110extern void *__dlmopen (Lmid_t nsid, const char *file, int mode DL_CALLER_DECL)
111 attribute_hidden;
112extern int __dlclose (void *handle)
113 attribute_hidden;
114extern void *__dlsym (void *handle, const char *name DL_CALLER_DECL)
115 attribute_hidden;
116extern void *__dlvsym (void *handle, const char *name, const char *version
117 DL_CALLER_DECL)
118 attribute_hidden;
119extern char *__dlerror (void)
120 attribute_hidden;
121extern int __dladdr (const void *address, Dl_info *info)
122 attribute_hidden;
123extern int __dladdr1 (const void *address, Dl_info *info,
124 void **extra_info, int flags)
125 attribute_hidden;
126extern int __dlinfo (void *handle, int request, void *arg DL_CALLER_DECL)
127 attribute_hidden;
128
129#ifndef SHARED
130struct link_map;
131extern void * __libc_dlsym_private (struct link_map *map, const char *name)
132 attribute_hidden;
133extern void __libc_register_dl_open_hook (struct link_map *map)
134 attribute_hidden;
135extern void __libc_register_dlfcn_hook (struct link_map *map)
136 attribute_hidden;
137#endif
31341567 138#endif
5f21997b 139
6796bc80 140#endif