diff options
Diffstat (limited to 'src/dlfcn/dlopen.c')
-rw-r--r-- | src/dlfcn/dlopen.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/dlfcn/dlopen.c b/src/dlfcn/dlopen.c new file mode 100644 index 00000000..f67e51ff --- /dev/null +++ b/src/dlfcn/dlopen.c @@ -0,0 +1,34 @@ +#include <dlfcn.h> +#include <fcntl.h> +#include <stdlib.h> +#include "_dlfcn.h" + +void *dlopen(const char *file, int mode) +{ + if ((mode & (RTLD_LAZY | RTLD_NOW)) == (RTLD_LAZY | RTLD_NOW)) { + return NULL; + } + + if ((mode & (RTLD_GLOBAL | RTLD_LOCAL)) == (RTLD_GLOBAL | RTLD_LOCAL)) { + return NULL; + } + + struct dlhandle *h = malloc(sizeof(*h)); + if (h == NULL) { + return NULL; + } + + h->fd = open(file, O_RDONLY | O_EXEC); + if (h->fd == -1) { + free(h); + return NULL; + } + + /* map and verify file header */ + + return h; +} + +/* +XOPEN(500) +*/ |