Created
July 9, 2013 16:01
-
-
Save arcanis/5958599 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/library.js b/src/library.js | |
index 84071b6..ae61697 100644 | |
--- a/src/library.js | |
+++ b/src/library.js | |
@@ -5794,7 +5794,7 @@ LibraryManager.library = { | |
dlopen: function(filename, flag) { | |
// void *dlopen(const char *file, int mode); | |
// http://pubs.opengroup.org/onlinepubs/009695399/functions/dlopen.html | |
- filename = (ENV['LD_LIBRARY_PATH'] || '/') + Pointer_stringify(filename); | |
+ filename = filename ? (ENV['LD_LIBRARY_PATH'] || '/') + Pointer_stringify(filename) : ''; | |
if (DLFCN_DATA.loadedLibNames[filename]) { | |
// Already loaded; increment ref count and return. | |
@@ -5803,17 +5803,19 @@ LibraryManager.library = { | |
return handle; | |
} | |
- var target = FS.findObject(filename); | |
- if (!target || target.isFolder || target.isDevice) { | |
+ var target = filename ? FS.findObject(filename) : null; | |
+ if (filename && (!target || target.isFolder || target.isDevice)) { | |
DLFCN_DATA.errorMsg = 'Could not find dynamic lib: ' + filename; | |
return 0; | |
- } else { | |
+ } else if (filename) { | |
FS.forceLoadFile(target); | |
var lib_data = intArrayToString(target.contents); | |
} | |
try { | |
- var lib_module = eval(lib_data)({{{ Functions.getTable('x') }}}.length); | |
+ var lib_module = filename | |
+ ? eval(lib_data)({{{ Functions.getTable('x') }}}.length) | |
+ : Module; | |
} catch (e) { | |
#if ASSERTIONS | |
Module.printErr('Error in loading dynamic library: ' + e); | |
@@ -5837,7 +5839,7 @@ LibraryManager.library = { | |
DLFCN_DATA.loadedLibNames[filename] = handle; | |
// We don't care about RTLD_NOW and RTLD_LAZY. | |
- if (flag & 256) { // RTLD_GLOBAL | |
+ if (flag & 256 && Module !== lib_module) { // RTLD_GLOBAL | |
for (var ident in lib_module) { | |
if (lib_module.hasOwnProperty(ident)) { | |
Module[ident] = lib_module[ident]; | |
@@ -7692,5 +7694,3 @@ function autoAddDeps(object, name) { | |
} | |
} | |
} | |
- | |
- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment