aboutsummaryrefslogtreecommitdiff
path: root/emscripten.py
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-07-15 15:24:54 -0700
committerAlon Zakai <alonzakai@gmail.com>2013-07-15 15:24:54 -0700
commit6e7a7aa3e8c2096463fed1f24d561557f49787f8 (patch)
treef81ea4377db6d4fd1b002cb55875d2291b71b62e /emscripten.py
parent9bf755607fc7a0e7f446a5e2d6c82738d77d876f (diff)
parent61c31f69359132e7630a9c4c2c3d25a6ed742247 (diff)
Merge branch 'self-dlopen' of github.com:int3/emscripten into incoming
Diffstat (limited to 'emscripten.py')
-rwxr-xr-xemscripten.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/emscripten.py b/emscripten.py
index 9a2abb9a..3e3538e9 100755
--- a/emscripten.py
+++ b/emscripten.py
@@ -9,7 +9,7 @@ header files (so that the JS compiler can see the constants in those
headers, for the libc implementation in JS).
'''
-import os, sys, json, optparse, subprocess, re, time, multiprocessing, functools
+import os, sys, json, optparse, subprocess, re, time, multiprocessing, string
from tools import shared
from tools import jsrun, cache as cache_module, tempfiles
@@ -625,6 +625,18 @@ Runtime.stackRestore = function(top) { asm['stackRestore'](top) };
// EMSCRIPTEN_END_FUNCS
''']
+ # Create symbol table for self-dlopen
+ if settings.get('DLOPEN_SUPPORT'):
+ symbol_table = { k:v+forwarded_json['Runtime']['GLOBAL_BASE']
+ for k,v in forwarded_json['Variables']['indexedGlobals'].iteritems()
+ if forwarded_json['Variables']['globals'][k]['named'] }
+ for raw in last_forwarded_json['Functions']['tables'].itervalues():
+ if raw == '': continue
+ table = map(string.strip, raw[raw.find('[')+1:raw.find(']')].split(","))
+ symbol_table.update(map(lambda x: (x[1], x[0]),
+ filter(lambda x: x[1] != '0', enumerate(table))))
+ outfile.write("var SYMBOL_TABLE = %s;" % json.dumps(symbol_table))
+
for funcs_js_item in funcs_js: # do this loop carefully to save memory
funcs_js_item = indexize(funcs_js_item)
funcs_js_item = blockaddrsize(funcs_js_item)