Skip to content

Commit

Permalink
emterpreter: support wildcards in EMTERPRETIFY_WHITELIST (emscripten-…
Browse files Browse the repository at this point in the history
  • Loading branch information
Beuc committed Feb 10, 2019
1 parent b81aceb commit 66c4e1d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 4 additions & 0 deletions ChangeLog.md
Expand Up @@ -23,6 +23,10 @@ Current Trunk
ad hoc constructed rules around default Emscripten uses. The old behavior
will be deprecated and removed in the future. Build with -s ASSERTIONS=1
to get diagnostics messages related to this transition.

- Option -s EMTERPRETIFY_WHITELIST now accepts shell-style wildcards;
this allows matching static functions with conflicting names that
the linker distinguishes by appending a random suffix.

v1.38.26: 02/04/2019
--------------------
Expand Down
10 changes: 8 additions & 2 deletions tools/emterpretify.py
Expand Up @@ -11,7 +11,7 @@
'''

from __future__ import print_function
import os, sys, re, json, shutil
import os, sys, re, json, shutil, fnmatch

sys.path.insert(1, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

Expand Down Expand Up @@ -50,6 +50,12 @@ def handle_arg(arg):
return False
return True

def wildcards_match(func, whitelist):
for w in whitelist:
if fnmatch.fnmatch(func, w):
return True
return False

DEBUG = os.environ.get('EMCC_DEBUG')

config = shared.Configuration()
Expand Down Expand Up @@ -782,7 +788,7 @@ def process(code):

if len(WHITELIST):
# we are using a whitelist: fill the blacklist with everything not whitelisted
BLACKLIST = set([func for func in asm.funcs if func not in WHITELIST])
BLACKLIST = set([func for func in asm.funcs if not wildcards_match(func, WHITELIST)])

# decide which functions will be emterpreted, and find which are externally reachable (from outside other emterpreted code; those will need trampolines)

Expand Down

0 comments on commit 66c4e1d

Please sign in to comment.