diff options
author | Jakob Kaivo <jkk@ung.org> | 2020-10-29 16:12:21 -0400 |
---|---|---|
committer | Jakob Kaivo <jkk@ung.org> | 2020-10-29 16:12:21 -0400 |
commit | 711f5a93cf708e9b40c2f937469934f270a02476 (patch) | |
tree | 5841b262daa6333b762f20ce0fe4798ba0fe1b3d /src/dlfcn/dlopen.c | |
parent | 972d2eee3a3518f18e0958e6f8a1b2ffafd6d39a (diff) |
outline <dlfcn.h>
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) +*/ |