forked from OSchip/llvm-project
[clang][driver] Support HWASan in the Fuchsia toolchain
These contain clang driver changes for supporting HWASan on Fuchsia. This includes hwasan multilibs and the dylib path change. Differential Revision: https://reviews.llvm.org/D99361
This commit is contained in:
parent
1c55dcbca7
commit
1abaadb30d
|
@ -95,6 +95,8 @@ void fuchsia::Linker::ConstructJob(Compilation &C, const JobAction &JA,
|
|||
std::string Dyld = D.DyldPrefix;
|
||||
if (SanArgs.needsAsanRt() && SanArgs.needsSharedRt())
|
||||
Dyld += "asan/";
|
||||
if (SanArgs.needsHwasanRt() && SanArgs.needsSharedRt())
|
||||
Dyld += "hwasan/";
|
||||
if (SanArgs.needsTsanRt() && SanArgs.needsSharedRt())
|
||||
Dyld += "tsan/";
|
||||
Dyld += "ld.so.1";
|
||||
|
@ -210,23 +212,41 @@ Fuchsia::Fuchsia(const Driver &D, const llvm::Triple &Triple,
|
|||
.flag("+fsanitize=address")
|
||||
.flag("-fexceptions")
|
||||
.flag("+fno-exceptions"));
|
||||
// HWASan has higher priority because we always want the instrumentated
|
||||
// version.
|
||||
Multilibs.push_back(
|
||||
Multilib("hwasan", {}, {}, 4).flag("+fsanitize=hwaddress"));
|
||||
// Use the hwasan+noexcept variant with HWASan and -fno-exceptions.
|
||||
Multilibs.push_back(Multilib("hwasan+noexcept", {}, {}, 5)
|
||||
.flag("+fsanitize=hwaddress")
|
||||
.flag("-fexceptions")
|
||||
.flag("+fno-exceptions"));
|
||||
// Use the relative vtables ABI.
|
||||
// TODO: Remove these multilibs once relative vtables are enabled by default
|
||||
// for Fuchsia.
|
||||
Multilibs.push_back(Multilib("relative-vtables", {}, {}, 4)
|
||||
Multilibs.push_back(Multilib("relative-vtables", {}, {}, 6)
|
||||
.flag("+fexperimental-relative-c++-abi-vtables"));
|
||||
Multilibs.push_back(Multilib("relative-vtables+noexcept", {}, {}, 5)
|
||||
Multilibs.push_back(Multilib("relative-vtables+noexcept", {}, {}, 7)
|
||||
.flag("+fexperimental-relative-c++-abi-vtables")
|
||||
.flag("-fexceptions")
|
||||
.flag("+fno-exceptions"));
|
||||
Multilibs.push_back(Multilib("relative-vtables+asan", {}, {}, 6)
|
||||
Multilibs.push_back(Multilib("relative-vtables+asan", {}, {}, 8)
|
||||
.flag("+fexperimental-relative-c++-abi-vtables")
|
||||
.flag("+fsanitize=address"));
|
||||
Multilibs.push_back(Multilib("relative-vtables+asan+noexcept", {}, {}, 7)
|
||||
Multilibs.push_back(Multilib("relative-vtables+asan+noexcept", {}, {}, 9)
|
||||
.flag("+fexperimental-relative-c++-abi-vtables")
|
||||
.flag("+fsanitize=address")
|
||||
.flag("-fexceptions")
|
||||
.flag("+fno-exceptions"));
|
||||
Multilibs.push_back(Multilib("relative-vtables+hwasan", {}, {}, 10)
|
||||
.flag("+fexperimental-relative-c++-abi-vtables")
|
||||
.flag("+fsanitize=hwaddress"));
|
||||
Multilibs.push_back(Multilib("relative-vtables+hwasan+noexcept", {}, {}, 11)
|
||||
.flag("+fexperimental-relative-c++-abi-vtables")
|
||||
.flag("+fsanitize=hwaddress")
|
||||
.flag("-fexceptions")
|
||||
.flag("+fno-exceptions"));
|
||||
|
||||
Multilibs.FilterOut([&](const Multilib &M) {
|
||||
std::vector<std::string> RD = FilePaths(M);
|
||||
return std::all_of(RD.begin(), RD.end(), [&](std::string P) {
|
||||
|
@ -239,6 +259,8 @@ Fuchsia::Fuchsia(const Driver &D, const llvm::Triple &Triple,
|
|||
Args.hasFlag(options::OPT_fexceptions, options::OPT_fno_exceptions, true),
|
||||
"fexceptions", Flags);
|
||||
addMultilibFlag(getSanitizerArgs().needsAsanRt(), "fsanitize=address", Flags);
|
||||
addMultilibFlag(getSanitizerArgs().needsHwasanRt(), "fsanitize=hwaddress",
|
||||
Flags);
|
||||
|
||||
addMultilibFlag(
|
||||
Args.hasFlag(options::OPT_fexperimental_relative_cxx_abi_vtables,
|
||||
|
@ -368,6 +390,7 @@ void Fuchsia::AddCXXStdlibLibArgs(const ArgList &Args,
|
|||
SanitizerMask Fuchsia::getSupportedSanitizers() const {
|
||||
SanitizerMask Res = ToolChain::getSupportedSanitizers();
|
||||
Res |= SanitizerKind::Address;
|
||||
Res |= SanitizerKind::HWAddress;
|
||||
Res |= SanitizerKind::PointerCompare;
|
||||
Res |= SanitizerKind::PointerSubtract;
|
||||
Res |= SanitizerKind::Fuzzer;
|
||||
|
|
|
@ -121,6 +121,26 @@
|
|||
// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
|
||||
// RUN: -fuse-ld=lld 2>&1\
|
||||
// RUN: | FileCheck %s -check-prefixes=CHECK-MULTILIB-X86
|
||||
// RUN: %clangxx %s -### --target=x86_64-fuchsia -fsanitize=hwaddress \
|
||||
// RUN: -ccc-install-dir %S/Inputs/basic_fuchsia_tree/bin \
|
||||
// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
|
||||
// RUN: -fuse-ld=lld 2>&1\
|
||||
// RUN: | FileCheck %s -check-prefixes=CHECK-MULTILIB-X86,CHECK-MULTILIB-HWASAN-X86
|
||||
// RUN: %clangxx %s -### --target=x86_64-fuchsia -fsanitize=hwaddress -fno-exceptions \
|
||||
// RUN: -ccc-install-dir %S/Inputs/basic_fuchsia_tree/bin \
|
||||
// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
|
||||
// RUN: -fuse-ld=lld 2>&1\
|
||||
// RUN: | FileCheck %s -check-prefixes=CHECK-MULTILIB-X86,CHECK-MULTILIB-HWASAN-NOEXCEPT-X86
|
||||
// RUN: %clangxx %s -### --target=x86_64-fuchsia -fexperimental-relative-c++-abi-vtables -fsanitize=hwaddress \
|
||||
// RUN: -ccc-install-dir %S/Inputs/basic_fuchsia_tree/bin \
|
||||
// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
|
||||
// RUN: -fuse-ld=lld 2>&1\
|
||||
// RUN: | FileCheck %s -check-prefixes=CHECK-MULTILIB-X86,CHECK-MULTILIB-RELATIVE-VTABLES-HWASAN-X86
|
||||
// RUN: %clangxx %s -### --target=x86_64-fuchsia -fexperimental-relative-c++-abi-vtables -fno-exceptions -fsanitize=hwaddress \
|
||||
// RUN: -ccc-install-dir %S/Inputs/basic_fuchsia_tree/bin \
|
||||
// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
|
||||
// RUN: -fuse-ld=lld 2>&1\
|
||||
// RUN: | FileCheck %s -check-prefixes=CHECK-MULTILIB-X86,CHECK-MULTILIB-RELATIVE-VTABLES-HWASAN-NOEXCEPT-X86
|
||||
// CHECK-MULTILIB-X86: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]"
|
||||
// CHECK-MULTILIB-ASAN-X86: "-L{{.*}}{{/|\\\\}}..{{/|\\\\}}lib{{/|\\\\}}x86_64-fuchsia{{/|\\\\}}c++{{/|\\\\}}asan"
|
||||
// CHECK-MULTILIB-NOEXCEPT-X86: "-L{{.*}}{{/|\\\\}}..{{/|\\\\}}lib{{/|\\\\}}x86_64-fuchsia{{/|\\\\}}c++{{/|\\\\}}noexcept"
|
||||
|
@ -129,4 +149,8 @@
|
|||
// CHECK-MULTILIB-RELATIVE-VTABLES-NOEXCEPT-X86: "-L{{.*}}{{/|\\\\}}..{{/|\\\\}}lib{{/|\\\\}}x86_64-fuchsia{{/|\\\\}}c++{{/|\\\\}}relative-vtables+noexcept"
|
||||
// CHECK-MULTILIB-RELATIVE-VTABLES-ASAN-X86: "-L{{.*}}{{/|\\\\}}..{{/|\\\\}}lib{{/|\\\\}}x86_64-fuchsia{{/|\\\\}}c++{{/|\\\\}}relative-vtables+asan"
|
||||
// CHECK-MULTILIB-RELATIVE-VTABLES-ASAN-NOEXCEPT-X86: "-L{{.*}}{{/|\\\\}}..{{/|\\\\}}lib{{/|\\\\}}x86_64-fuchsia{{/|\\\\}}c++{{/|\\\\}}relative-vtables+asan+noexcept"
|
||||
// CHECK-MULTILIB-HWASAN-X86: "-L{{.*}}{{/|\\\\}}..{{/|\\\\}}lib{{/|\\\\}}x86_64-fuchsia{{/|\\\\}}c++{{/|\\\\}}hwasan"
|
||||
// CHECK-MULTILIB-HWASAN-NOEXCEPT-X86: "-L{{.*}}{{/|\\\\}}..{{/|\\\\}}lib{{/|\\\\}}x86_64-fuchsia{{/|\\\\}}c++{{/|\\\\}}hwasan+noexcept"
|
||||
// CHECK-MULTILIB-RELATIVE-VTABLES-HWASAN-X86: "-L{{.*}}{{/|\\\\}}..{{/|\\\\}}lib{{/|\\\\}}x86_64-fuchsia{{/|\\\\}}c++{{/|\\\\}}relative-vtables+hwasan"
|
||||
// CHECK-MULTILIB-RELATIVE-VTABLES-HWASAN-NOEXCEPT-X86: "-L{{.*}}{{/|\\\\}}..{{/|\\\\}}lib{{/|\\\\}}x86_64-fuchsia{{/|\\\\}}c++{{/|\\\\}}relative-vtables+hwasan+noexcept"
|
||||
// CHECK-MULTILIB-X86: "-L{{.*}}{{/|\\\\}}..{{/|\\\\}}lib{{/|\\\\}}x86_64-fuchsia{{/|\\\\}}c++"
|
||||
|
|
Loading…
Reference in New Issue