[clang] 39ba913 - [Driver] -fsanitize=function: unsupport wasm after D148573
Fangrui Song via cfe-commits
cfe-commits at lists.llvm.org
Mon May 22 10:40:09 PDT 2023
Author: Fangrui Song
Date: 2023-05-22T10:40:04-07:00
New Revision: 39ba913d13ab15c76cb6b5aa066fa111ddfe944b
URL: https://github.com/llvm/llvm-project/commit/39ba913d13ab15c76cb6b5aa066fa111ddfe944b
DIFF: https://github.com/llvm/llvm-project/commit/39ba913d13ab15c76cb6b5aa066fa111ddfe944b.diff
LOG: [Driver] -fsanitize=function: unsupport wasm after D148573
D148573 made x86-specific -fsanitize=function available to all targets,
but wasm doesn't allow placing data words before the function label,
so unsupport wasm.
Added:
Modified:
clang/lib/Driver/ToolChains/WebAssembly.cpp
clang/test/Driver/wasm-toolchain.c
Removed:
################################################################################
diff --git a/clang/lib/Driver/ToolChains/WebAssembly.cpp b/clang/lib/Driver/ToolChains/WebAssembly.cpp
index a1c4cd9ef9c79..016b70b1c2ede 100644
--- a/clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ b/clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -459,6 +459,9 @@ SanitizerMask WebAssembly::getSupportedSanitizers() const {
if (getTriple().isOSEmscripten()) {
Res |= SanitizerKind::Vptr | SanitizerKind::Leak | SanitizerKind::Address;
}
+ // -fsanitize=function places two words before the function label, which are
+ // -unsupported.
+ Res &= ~SanitizerKind::Function;
return Res;
}
diff --git a/clang/test/Driver/wasm-toolchain.c b/clang/test/Driver/wasm-toolchain.c
index f391b2802308d..bfe696d7846e7 100644
--- a/clang/test/Driver/wasm-toolchain.c
+++ b/clang/test/Driver/wasm-toolchain.c
@@ -146,6 +146,9 @@
// CHECK-ASAN-EMSCRIPTEN: "-fsanitize=address"
// CHECK-ASAN-EMSCRIPTEN: "-fsanitize-address-globals-dead-stripping"
+// RUN: %clang -### %s -fsanitize=function --target=wasm32-unknown-emscripten 2>&1 | FileCheck --check-prefix=FUNCTION %s
+// FUNCTION: error: unsupported option '-fsanitize=function' for target 'wasm32-unknown-emscripten'
+
// Basic exec-model tests.
// RUN: %clang -### %s --target=wasm32-unknown-unknown --sysroot=%s/no-sysroot-there -mexec-model=command 2>&1 \
More information about the cfe-commits
mailing list