blob: f67e51ff15f978b372777988726335c9ec0185c8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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)
*/
|