Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(596)

Unified Diff: binutils-2.20/dlwrap.c

Issue 8713008: Add dlwrap.c to binutils to simulate dlopen/dlsym for gold plugin (Closed)
Patch Set: x Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « binutils-2.20/dlwrap.h ('k') | binutils-2.20/gold/Makefile.in » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
+}
« no previous file with comments | « binutils-2.20/dlwrap.h ('k') | binutils-2.20/gold/Makefile.in » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698