[PATCH] D62559: [WebAssembly] Support VPtr sanitizer for Emscripten

Guanzhong Chen via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 28 16:55:01 PDT 2019


quantum created this revision.
quantum added reviewers: tlively, aheejin.
Herald added subscribers: cfe-commits, sunfish, jgravelle-google, sbc100, dschuff.
Herald added a project: clang.

After https://github.com/emscripten-core/emscripten/pull/8651, Emscripten
supports the full UBSan runtime. This includes the VPtr sanitizer.

This diff allows clang to generate code that uses the VPtr sanitizer for
Emscripten.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D62559

Files:
  clang/lib/Driver/ToolChains/WebAssembly.cpp
  clang/lib/Driver/ToolChains/WebAssembly.h


Index: clang/lib/Driver/ToolChains/WebAssembly.h
===================================================================
--- clang/lib/Driver/ToolChains/WebAssembly.h
+++ clang/lib/Driver/ToolChains/WebAssembly.h
@@ -66,6 +66,7 @@
       llvm::opt::ArgStringList &CC1Args) const override;
   void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
                            llvm::opt::ArgStringList &CmdArgs) const override;
+  SanitizerMask getSupportedSanitizers() const override;
 
   const char *getDefaultLinker() const override { return "wasm-ld"; }
 
Index: clang/lib/Driver/ToolChains/WebAssembly.cpp
===================================================================
--- clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -208,6 +208,14 @@
   }
 }
 
+SanitizerMask WebAssembly::getSupportedSanitizers() const {
+  SanitizerMask Res = ToolChain::getSupportedSanitizers();
+  if (getTriple().isOSEmscripten()) {
+    Res |= SanitizerKind::Vptr;
+  }
+  return Res;
+}
+
 Tool *WebAssembly::buildLinker() const {
   return new tools::wasm::Linker(*this);
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62559.201789.patch
Type: text/x-patch
Size: 1108 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190528/4ef5dca3/attachment.bin>


More information about the cfe-commits mailing list