Skip to content

Commit 0c48c33

Browse files
committed
Merge branch 'incoming' of https://github.com/ddcc/emscripten into incoming
2 parents 0a8bf0b + dd8316c commit 0c48c33

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,3 +254,4 @@ a license to everyone to use it as detailed in LICENSE.)
254254
* Dustin VanLerberghe <[email protected]>
255255
* Philip Bielby <[email protected]> (copyright owned by Jagex Ltd.)
256256
* Régis Fénéon <[email protected]>
257+
* Dominic Chen <[email protected]> (copyright owned by Google, Inc.)

emcc.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,7 @@ def log_time(name):
436436
default_object_extension = '.o'
437437
valid_abspaths = []
438438
separate_asm = False
439+
cfi = False
439440

440441
def is_valid_abspath(path_name):
441442
# Any path that is underneath the emscripten repository root must be ok.
@@ -724,6 +725,8 @@ def detect_fixed_language_mode(args):
724725
newargs.append('-D__SSSE3__=1')
725726
newargs.append('-D__SSE4_1__=1')
726727
newargs[i] = ''
728+
elif newargs[i].startswith("-fsanitize=cfi"):
729+
cfi = True
727730

728731
if should_exit:
729732
sys.exit(0)
@@ -1443,6 +1446,11 @@ def save_intermediate(name=None, suffix='js'):
14431446
# At minimum remove dead functions etc., this potentially saves a lot in the size of the generated code (and the time to compile it)
14441447
link_opts += shared.Building.get_safe_internalize() + ['-globaldce']
14451448

1449+
if cfi:
1450+
if use_cxx:
1451+
link_opts.append("-wholeprogramdevirt")
1452+
link_opts.append("-lowertypetests")
1453+
14461454
if AUTODEBUG:
14471455
# let llvm opt directly emit ll, to skip writing and reading all the bitcode
14481456
link_opts += ['-S']

site/build/text/docs/tools_reference/emcc.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,15 @@ Options that are modified or new in *emcc* are listed below:
546546
load during startup. See Avoid memory spikes by separating out
547547
asm.js.
548548

549+
"-fsanitize=<check>"
550+
Instructs the compiler to turn on runtime checks for various forms
551+
of undefined or suspicious behavior. For more information, refer
552+
to the appropriate compiler documentation. Only the following have
553+
been tested:
554+
555+
* "cfi": Enable [control flow integrity](http://clang.llvm.org/docs/ControlFlowIntegrity.html)
556+
checks. Note that this is only supported by Clang/LLVM, and
557+
indirect function call checking requires Clang/LLVM 3.9+.
549558

550559
Environment variables
551560
=====================

0 commit comments

Comments
 (0)