Index: binutils-2.20/dlwrap.c |
=================================================================== |
new file mode 100644 |
--- /dev/null |
+++ b/binutils-2.20/dlwrap.c |
@@ -0,0 +1,64 @@ |
+#include <stdio.h> |
+#include <string.h> |
+ |
sehr (please use chromium)
2012/02/15 19:47:57
Please add explicitly a comment that this is a hac
|
+/* This must match RTLD_NOW in dlwrap.h */ |
+#define PNACL_RTLD_NOW 0x2 |
+ |
+static int dummy; |
+static int haserr = 0; |
+static char errmsg[200]; |
+ |
+/* This is not the real signature of this function, |
+ * but we just need the symbol address. |
+ */ |
+#ifdef HAS_LLVM_PLUGIN |
+void llvm_plugin_onload(); |
+#endif |
+ |
+void *pnacl_dlopen(const char *filename, int flag) { |
+ void *ret; |
+ if (flag != 0 && flag != PNACL_RTLD_NOW) { |
+ sprintf(errmsg, "Error: Unknown flag to pnacl_dlopen: %d\n", flag); |
+ haserr = 1; |
+ return NULL; |
+ } |
+ if (strstr(filename, "LLVMgold") == NULL) { |
+ sprintf(errmsg, "Error: Unexpected pnacl_dlopen: %s\n", filename); |
+ haserr = 1; |
+ return NULL; |
+ } |
+ return (void*)&dummy; |
+} |
+ |
+char *pnacl_dlerror(void) { |
+ if (haserr) { |
+ haserr = 0; |
+ return errmsg; |
+ } |
+ return NULL; |
+} |
+ |
+void *pnacl_dlsym(void *handle, const char *symbol) { |
+ if (handle != (void*)&dummy) { |
+ sprintf(errmsg, "Error: Unexpected pnacl_dlsym handle\n"); |
+ haserr = 1; |
+ return NULL; |
+ } |
+ |
+ if (strcmp(symbol, "onload") != 0) { |
+ sprintf(errmsg, "Error: Unexpected pnacl_dlsym symbol: %s\n", symbol); |
+ haserr = 1; |
+ return NULL; |
+ } |
+#ifdef HAS_LLVM_PLUGIN |
+ return (void*)&llvm_plugin_onload; |
+#else |
+ sprintf(errmsg, "Error: LLVM plugin not available\n"); |
+ haserr = 1; |
+ return NULL; |
+#endif |
+} |
+ |
+int pnacl_dlclose(void *handle) { |
+ return 0; |
+} |