126 lines
3.2 KiB
C
126 lines
3.2 KiB
C
#ifndef _DLFCN_H
|
|
#define _DLFCN_H 1
|
|
|
|
#include <stdint.h>
|
|
|
|
enum DLOPEN_FLAGS
|
|
{
|
|
/*
|
|
Perform lazy binding. Resolve symbols only as the code
|
|
that references them is executed. If the symbol is never
|
|
referenced, then it is never resolved. (Lazy binding is
|
|
performed only for function references; references to
|
|
variables are always immediately bound when the shared
|
|
object is loaded.).
|
|
*/
|
|
RTLD_LAZY,
|
|
|
|
/*
|
|
If this value is specified, or the environment variable
|
|
LD_BIND_NOW is set to a nonempty string, all undefined
|
|
symbols in the shared object are resolved before dlopen()
|
|
returns. If this cannot be done, an error is returned.
|
|
|
|
Zero or more of the following values may also be ORed in flags:
|
|
*/
|
|
RTLD_NOW,
|
|
|
|
/*
|
|
The symbols defined by this shared object will be made
|
|
available for symbol resolution of subsequently loaded
|
|
shared objects.
|
|
*/
|
|
RTLD_GLOBAL,
|
|
|
|
/*
|
|
This is the converse of RTLD_GLOBAL, and the default if
|
|
neither flag is specified. Symbols defined in this shared
|
|
object are not made available to resolve references in
|
|
subsequently loaded shared objects.
|
|
*/
|
|
RTLD_LOCAL,
|
|
|
|
/*
|
|
Do not unload the shared object during dlclose().
|
|
Consequently, the object's static and global variables are
|
|
not reinitialized if the object is reloaded with dlopen()
|
|
at a later time.
|
|
*/
|
|
RTLD_NODELETE,
|
|
|
|
/*
|
|
Don't load the shared object. This can be used to test if
|
|
the object is already resident (dlopen() returns NULL if it
|
|
is not, or the object's handle if it is resident). This
|
|
flag can also be used to promote the flags on a shared
|
|
object that is already loaded. For example, a shared
|
|
object that was previously loaded with RTLD_LOCAL can be
|
|
reopened with RTLD_NOLOAD | RTLD_GLOBAL.
|
|
*/
|
|
RTLD_NOLOAD,
|
|
|
|
/*
|
|
Place the lookup scope of the symbols in this shared object
|
|
ahead of the global scope. This means that a self-
|
|
contained object will use its own symbols in preference to
|
|
global symbols with the same name contained in objects that
|
|
have already been loaded.
|
|
*/
|
|
RTLD_DEEPBIND,
|
|
|
|
RTLD_DL_LINKMAP,
|
|
|
|
RTLD_DL_SYMENT
|
|
};
|
|
|
|
enum DLOPEN_NSID
|
|
{
|
|
/*
|
|
Load the shared object in the initial namespace (i.e., the
|
|
application's namespace).
|
|
*/
|
|
LM_ID_BASE,
|
|
|
|
/*
|
|
Create a new namespace and load the shared object in that
|
|
namespace. The object must have been correctly linked to
|
|
reference all of the other shared objects that it requires,
|
|
since the new namespace is initially empty.
|
|
If path is NULL, then the only permitted value for lmid is LM_ID_BASE
|
|
*/
|
|
LM_ID_NEWLM,
|
|
};
|
|
|
|
typedef struct
|
|
{
|
|
/*
|
|
Pathname of shared object that contains address
|
|
*/
|
|
const char *dli_fname;
|
|
/*
|
|
Base address at which shared object is loaded
|
|
*/
|
|
void *dli_fbase;
|
|
/*
|
|
Name of symbol whose definition overlaps addr
|
|
*/
|
|
const char *dli_sname;
|
|
/*
|
|
Exact address of symbol named in dli_sname
|
|
*/
|
|
void *dli_saddr;
|
|
} Dl_info;
|
|
|
|
void *dlopen(const char *filename, int flag);
|
|
const char *dlerror(void);
|
|
void *dlsym(void *handle, char *symbol);
|
|
int dlclose(void *handle);
|
|
|
|
void *dlmopen(enum DLOPEN_NSID nsid, const char *file, int mode);
|
|
|
|
int dladdr(const void *addr, Dl_info *info);
|
|
int dladdr1(const void *addr, Dl_info *info, void **extra_info,
|
|
int flags);
|
|
|
|
#endif // _DLFCN_H
|