OLD | NEW |
---|---|
(Empty) | |
1 #include <stdio.h> | |
2 #include <string.h> | |
3 | |
sehr (please use chromium)
2012/02/15 19:47:57
Please add explicitly a comment that this is a hac
| |
4 /* This must match RTLD_NOW in dlwrap.h */ | |
5 #define PNACL_RTLD_NOW 0x2 | |
6 | |
7 static int dummy; | |
8 static int haserr = 0; | |
9 static char errmsg[200]; | |
10 | |
11 /* This is not the real signature of this function, | |
12 * but we just need the symbol address. | |
13 */ | |
14 #ifdef HAS_LLVM_PLUGIN | |
15 void llvm_plugin_onload(); | |
16 #endif | |
17 | |
18 void *pnacl_dlopen(const char *filename, int flag) { | |
19 void *ret; | |
20 if (flag != 0 && flag != PNACL_RTLD_NOW) { | |
21 sprintf(errmsg, "Error: Unknown flag to pnacl_dlopen: %d\n", flag); | |
22 haserr = 1; | |
23 return NULL; | |
24 } | |
25 if (strstr(filename, "LLVMgold") == NULL) { | |
26 sprintf(errmsg, "Error: Unexpected pnacl_dlopen: %s\n", filename); | |
27 haserr = 1; | |
28 return NULL; | |
29 } | |
30 return (void*)&dummy; | |
31 } | |
32 | |
33 char *pnacl_dlerror(void) { | |
34 if (haserr) { | |
35 haserr = 0; | |
36 return errmsg; | |
37 } | |
38 return NULL; | |
39 } | |
40 | |
41 void *pnacl_dlsym(void *handle, const char *symbol) { | |
42 if (handle != (void*)&dummy) { | |
43 sprintf(errmsg, "Error: Unexpected pnacl_dlsym handle\n"); | |
44 haserr = 1; | |
45 return NULL; | |
46 } | |
47 | |
48 if (strcmp(symbol, "onload") != 0) { | |
49 sprintf(errmsg, "Error: Unexpected pnacl_dlsym symbol: %s\n", symbol); | |
50 haserr = 1; | |
51 return NULL; | |
52 } | |
53 #ifdef HAS_LLVM_PLUGIN | |
54 return (void*)&llvm_plugin_onload; | |
55 #else | |
56 sprintf(errmsg, "Error: LLVM plugin not available\n"); | |
57 haserr = 1; | |
58 return NULL; | |
59 #endif | |
60 } | |
61 | |
62 int pnacl_dlclose(void *handle) { | |
63 return 0; | |
64 } | |
OLD | NEW |