Index: lib/Driver/SanitizerArgs.cpp =================================================================== --- lib/Driver/SanitizerArgs.cpp +++ lib/Driver/SanitizerArgs.cpp @@ -30,7 +30,7 @@ NeedsUbsanCxxRt = Vptr | CFI, NotAllowedWithTrap = Vptr, NotAllowedWithMinimalRuntime = Vptr, - RequiresPIE = DataFlow | Scudo, + RequiresPIE = DataFlow | HWAddress | Scudo, NeedsUnwindTables = Address | HWAddress | Thread | Memory | DataFlow, SupportsCoverage = Address | HWAddress | KernelAddress | Memory | Leak | Undefined | Integer | Nullability | DataFlow | Fuzzer | Index: lib/Driver/ToolChains/Linux.cpp =================================================================== --- lib/Driver/ToolChains/Linux.cpp +++ lib/Driver/ToolChains/Linux.cpp @@ -879,7 +879,7 @@ Res |= SanitizerKind::Function; if (IsX86_64 || IsMIPS64 || IsAArch64 || IsX86 || IsMIPS || IsArmArch) Res |= SanitizerKind::Scudo; - if (IsAArch64) + if (IsX86_64 || IsAArch64) Res |= SanitizerKind::HWAddress; return Res; } Index: test/Driver/fsanitize-blacklist.c =================================================================== --- test/Driver/fsanitize-blacklist.c +++ test/Driver/fsanitize-blacklist.c @@ -23,7 +23,7 @@ // Check that the default blacklist is not added as an extra dependency. // RUN: %clang -target x86_64-linux-gnu -fsanitize=address -resource-dir=%S/Inputs/resource_dir %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-DEFAULT-BLACKLIST-ASAN --implicit-check-not=fdepfile-entry --implicit-check-not=-fsanitize-blacklist= // CHECK-DEFAULT-BLACKLIST-ASAN: -fsanitize-blacklist={{.*[^w]}}asan_blacklist.txt -// RUN: %clang -target aarch64-linux-gnu -fsanitize=hwaddress -resource-dir=%S/Inputs/resource_dir %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-DEFAULT-BLACKLIST-HWASAN --implicit-check-not=fdepfile-entry --implicit-check-not=-fsanitize-blacklist= +// RUN: %clang -target x86_64-linux-gnu -fsanitize=hwaddress -resource-dir=%S/Inputs/resource_dir %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-DEFAULT-BLACKLIST-HWASAN --implicit-check-not=fdepfile-entry --implicit-check-not=-fsanitize-blacklist= // CHECK-DEFAULT-BLACKLIST-HWASAN: -fsanitize-blacklist={{.*}}hwasan_blacklist.txt // RUN: %clang -target x86_64-linux-gnu -fsanitize=integer -resource-dir=%S/Inputs/resource_dir %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-DEFAULT-UBSAN-BLACKLIST --implicit-check-not=fdepfile-entry --implicit-check-not=-fsanitize-blacklist= Index: test/Driver/fsanitize.c =================================================================== --- test/Driver/fsanitize.c +++ test/Driver/fsanitize.c @@ -83,13 +83,13 @@ // RUN: %clang -target x86_64-linux-gnu -fsanitize=kernel-address,address -fno-rtti %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANKA-SANA // CHECK-SANKA-SANA: '-fsanitize=kernel-address' not allowed with '-fsanitize=address' -// RUN: %clang -target aarch64-linux-gnu -fsanitize=hwaddress,thread -fno-rtti %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANHA-SANT +// RUN: %clang -target x86_64-linux-gnu -fsanitize=hwaddress,thread -fno-rtti %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANHA-SANT // CHECK-SANHA-SANT: '-fsanitize=hwaddress' not allowed with '-fsanitize=thread' -// RUN: %clang -target aarch64-linux-gnu -fsanitize=hwaddress,memory -pie -fno-rtti %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANHA-SANM +// RUN: %clang -target x86_64-linux-gnu -fsanitize=hwaddress,memory -pie -fno-rtti %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANHA-SANM // CHECK-SANHA-SANM: '-fsanitize=hwaddress' not allowed with '-fsanitize=memory' -// RUN: %clang -target aarch64-linux-gnu -fsanitize=hwaddress,address -fno-rtti %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANHA-SANA +// RUN: %clang -target x86_64-linux-gnu -fsanitize=hwaddress,address -fno-rtti %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANHA-SANA // CHECK-SANHA-SANA: '-fsanitize=hwaddress' not allowed with '-fsanitize=address' // RUN: %clang -target x86_64-linux-gnu -fsanitize=kernel-address,leak -pie -fno-rtti %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANKA-SANL @@ -487,7 +487,7 @@ // RUN: %clang -target x86_64-linux-gnu -fsanitize-trap=address -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-TRAP // CHECK-ASAN-TRAP: error: unsupported argument 'address' to option '-fsanitize-trap' -// RUN: %clang -target aarch64-linux-gnu -fsanitize-trap=hwaddress -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-HWASAN-TRAP +// RUN: %clang -target x86_64-linux-gnu -fsanitize-trap=hwaddress -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-HWASAN-TRAP // CHECK-HWASAN-TRAP: error: unsupported argument 'hwaddress' to option '-fsanitize-trap' // RUN: %clang -target x86_64-apple-darwin10 -mmacosx-version-min=10.7 -flto -fsanitize=cfi-vcall -fno-sanitize-trap=cfi -c %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CFI-NOTRAP-OLD-MACOS @@ -618,7 +618,7 @@ // RUN: %clang -target x86_64-linux-gnu -fsanitize=address -fsanitize-minimal-runtime -fsanitize=undefined %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-UBSAN-MINIMAL // CHECK-ASAN-UBSAN-MINIMAL: error: invalid argument '-fsanitize-minimal-runtime' not allowed with '-fsanitize=address' -// RUN: %clang -target aarch64-linux-gnu -fsanitize=hwaddress -fsanitize-minimal-runtime %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-HWASAN-MINIMAL +// RUN: %clang -target x86_64-linux-gnu -fsanitize=hwaddress -fsanitize-minimal-runtime %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-HWASAN-MINIMAL // CHECK-HWASAN-MINIMAL: error: invalid argument '-fsanitize-minimal-runtime' not allowed with '-fsanitize=hwaddress' // RUN: %clang -target x86_64-linux-gnu -fsanitize=cfi -flto -fvisibility=hidden -fsanitize-minimal-runtime %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-CFI-MINIMAL @@ -663,8 +663,5 @@ // CHECK-SCUDO-MSAN: error: invalid argument '-fsanitize=scudo' not allowed with '-fsanitize=memory' // RUN: %clang -target x86_64-linux-gnu -fsanitize=scudo,thread %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SCUDO-TSAN // CHECK-SCUDO-TSAN: error: invalid argument '-fsanitize=scudo' not allowed with '-fsanitize=thread' -// RUN: %clang -target aarch64-linux-gnu -fsanitize=scudo,hwaddress %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SCUDO-HWASAN +// RUN: %clang -target x86_64-linux-gnu -fsanitize=scudo,hwaddress %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SCUDO-HWASAN // CHECK-SCUDO-HWASAN: error: invalid argument '-fsanitize=scudo' not allowed with '-fsanitize=hwaddress' - -// RUN: %clang -target x86_64-linux-gnu -fsanitize=hwaddress %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANHA-X86_64 -// CHECK-SANHA-X86_64: unsupported option '-fsanitize=hwaddress' for target Index: test/Driver/sanitizer-ld.c =================================================================== --- test/Driver/sanitizer-ld.c +++ test/Driver/sanitizer-ld.c @@ -696,54 +696,100 @@ // CHECK-SCUDO-ANDROID-STATIC: "-lpthread" // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ -// RUN: -target aarch64-unknown-linux -fuse-ld=ld -fsanitize=hwaddress \ +// RUN: -target x86_64-unknown-linux -fuse-ld=ld -fsanitize=hwaddress \ // RUN: -resource-dir=%S/Inputs/resource_dir \ // RUN: --sysroot=%S/Inputs/basic_linux_tree \ -// RUN: | FileCheck --check-prefix=CHECK-HWASAN-LINUX %s +// RUN: | FileCheck --check-prefix=CHECK-HWASAN-X86-64-LINUX %s // -// CHECK-HWASAN-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}" -// CHECK-HWASAN-LINUX-NOT: "-lc" -// CHECK-HWASAN-LINUX: libclang_rt.hwasan-aarch64.a" -// CHECK-HWASAN-LINUX-NOT: "--export-dynamic" -// CHECK-HWASAN-LINUX: "--dynamic-list={{.*}}libclang_rt.hwasan-aarch64.a.syms" -// CHECK-HWASAN-LINUX-NOT: "--export-dynamic" -// CHECK-HWASAN-LINUX: "-lpthread" -// CHECK-HWASAN-LINUX: "-lrt" -// CHECK-HWASAN-LINUX: "-ldl" +// CHECK-HWASAN-X86-64-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}" +// CHECK-HWASAN-X86-64-LINUX: "-pie" +// CHECK-HWASAN-X86-64-LINUX-NOT: "-lc" +// CHECK-HWASAN-X86-64-LINUX: libclang_rt.hwasan-x86_64.a" +// CHECK-HWASAN-X86-64-LINUX-NOT: "--export-dynamic" +// CHECK-HWASAN-X86-64-LINUX: "--dynamic-list={{.*}}libclang_rt.hwasan-x86_64.a.syms" +// CHECK-HWASAN-X86-64-LINUX-NOT: "--export-dynamic" +// CHECK-HWASAN-X86-64-LINUX: "-lpthread" +// CHECK-HWASAN-X86-64-LINUX: "-lrt" +// CHECK-HWASAN-X86-64-LINUX: "-ldl" // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ -// RUN: -target aarch64-unknown-linux -fuse-ld=ld -fsanitize=hwaddress -shared-libsan \ -// RUN: -resource-dir=%S/Inputs/resource_dir \ +// RUN: -target x86_64-unknown-linux -fuse-ld=ld -fsanitize=hwaddress \ +// RUN: -shared-libsan -resource-dir=%S/Inputs/resource_dir \ +// RUN: --sysroot=%S/Inputs/basic_linux_tree \ +// RUN: | FileCheck --check-prefix=CHECK-SHARED-HWASAN-X86-64-LINUX %s +// +// CHECK-SHARED-HWASAN-X86-64-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}" +// CHECK-SHARED-HWASAN-X86-64-LINUX: "-pie" +// CHECK-SHARED-HWASAN-X86-64-LINUX-NOT: "-lc" +// CHECK-SHARED-HWASAN-X86-64-LINUX: libclang_rt.hwasan-x86_64.so" +// CHECK-SHARED-HWASAN-X86-64-LINUX-NOT: "-lpthread" +// CHECK-SHARED-HWASAN-X86-64-LINUX-NOT: "-lrt" +// CHECK-SHARED-HWASAN-X86-64-LINUX-NOT: "-ldl" +// CHECK-SHARED-HWASAN-X86-64-LINUX-NOT: "--export-dynamic" +// CHECK-SHARED-HWASAN-X86-64-LINUX-NOT: "--dynamic-list" + +// RUN: %clang -no-canonical-prefixes %s -### -o %t.so -shared 2>&1 \ +// RUN: -target x86_64-unknown-linux -fuse-ld=ld -fsanitize=hwaddress \ +// RUN: -shared-libsan -resource-dir=%S/Inputs/resource_dir \ // RUN: --sysroot=%S/Inputs/basic_linux_tree \ -// RUN: | FileCheck --check-prefix=CHECK-SHARED-HWASAN-LINUX %s +// RUN: | FileCheck --check-prefix=CHECK-DSO-SHARED-HWASAN-X86-64-LINUX %s +// +// CHECK-DSO-SHARED-HWASAN-X86-64-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}" +// CHECK-DSO_SHARED-HWASAN-X86-64-LINUX: "-pie" +// CHECK-DSO-SHARED-HWASAN-X86-64-LINUX-NOT: "-lc" +// CHECK-DSO-SHARED-HWASAN-X86-64-LINUX: libclang_rt.hwasan-x86_64.so" +// CHECK-DSO-SHARED-HWASAN-X86-64-LINUX-NOT: "-lpthread" +// CHECK-DSO-SHARED-HWASAN-X86-64-LINUX-NOT: "-lrt" +// CHECK-DSO-SHARED-HWASAN-X86-64-LINUX-NOT: "-ldl" +// CHECK-DSO-SHARED-HWASAN-X86-64-LINUX-NOT: "--export-dynamic" +// CHECK-DSO-SHARED-HWASAN-X86-64-LINUX-NOT: "--dynamic-list" // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: -target aarch64-unknown-linux -fuse-ld=ld -fsanitize=hwaddress \ -// RUN: -shared-libsan \ // RUN: -resource-dir=%S/Inputs/resource_dir \ // RUN: --sysroot=%S/Inputs/basic_linux_tree \ -// RUN: | FileCheck --check-prefix=CHECK-SHARED-HWASAN-LINUX %s +// RUN: | FileCheck --check-prefix=CHECK-HWASAN-AARCH64-LINUX %s // -// CHECK-SHARED-HWASAN-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}" -// CHECK-SHARED-HWASAN-LINUX-NOT: "-lc" -// CHECK-SHARED-HWASAN-LINUX: libclang_rt.hwasan-aarch64.so" -// CHECK-SHARED-HWASAN-LINUX-NOT: "-lpthread" -// CHECK-SHARED-HWASAN-LINUX-NOT: "-lrt" -// CHECK-SHARED-HWASAN-LINUX-NOT: "-ldl" -// CHECK-SHARED-HWASAN-LINUX-NOT: "--export-dynamic" -// CHECK-SHARED-HWASAN-LINUX-NOT: "--dynamic-list" +// CHECK-HWASAN-AARCH64-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}" +// CHECK-HWASAN-AARCH64-LINUX: "-pie" +// CHECK-HWASAN-AARCH64-LINUX-NOT: "-lc" +// CHECK-HWASAN-AARCH64-LINUX: libclang_rt.hwasan-aarch64.a" +// CHECK-HWASAN-AARCH64-LINUX-NOT: "--export-dynamic" +// CHECK-HWASAN-AARCH64-LINUX: "--dynamic-list={{.*}}libclang_rt.hwasan-aarch64.a.syms" +// CHECK-HWASAN-AARCH64-LINUX-NOT: "--export-dynamic" +// CHECK-HWASAN-AARCH64-LINUX: "-lpthread" +// CHECK-HWASAN-AARCH64-LINUX: "-lrt" +// CHECK-HWASAN-AARCH64-LINUX: "-ldl" -// RUN: %clang -no-canonical-prefixes %s -### -o %t.so -shared 2>&1 \ -// RUN: -target aarch64-unknown-linux -fuse-ld=ld -fsanitize=hwaddress -shared-libsan \ +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -target aarch64-unknown-linux -fuse-ld=ld -fsanitize=hwaddress \ +// RUN: -shared-libsan \ // RUN: -resource-dir=%S/Inputs/resource_dir \ // RUN: --sysroot=%S/Inputs/basic_linux_tree \ -// RUN: | FileCheck --check-prefix=CHECK-DSO-SHARED-HWASAN-LINUX %s +// RUN: | FileCheck --check-prefix=CHECK-SHARED-HWASAN-AARCH64-LINUX %s // -// CHECK-DSO-SHARED-HWASAN-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}" -// CHECK-DSO-SHARED-HWASAN-LINUX-NOT: "-lc" -// CHECK-DSO-SHARED-HWASAN-LINUX: libclang_rt.hwasan-aarch64.so" -// CHECK-DSO-SHARED-HWASAN-LINUX-NOT: "-lpthread" -// CHECK-DSO-SHARED-HWASAN-LINUX-NOT: "-lrt" -// CHECK-DSO-SHARED-HWASAN-LINUX-NOT: "-ldl" -// CHECK-DSO-SHARED-HWASAN-LINUX-NOT: "--export-dynamic" -// CHECK-DSO-SHARED-HWASAN-LINUX-NOT: "--dynamic-list" +// CHECK-SHARED-HWASAN-AARCH64-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}" +// CHECK-SHARED-HWASAN-AARCH64-LINUX: "-pie" +// CHECK-SHARED-HWASAN-AARCH64-LINUX-NOT: "-lc" +// CHECK-SHARED-HWASAN-AARCH64-LINUX: libclang_rt.hwasan-aarch64.so" +// CHECK-SHARED-HWASAN-AARCH64-LINUX-NOT: "-lpthread" +// CHECK-SHARED-HWASAN-AARCH64-LINUX-NOT: "-lrt" +// CHECK-SHARED-HWASAN-AARCH64-LINUX-NOT: "-ldl" +// CHECK-SHARED-HWASAN-AARCH64-LINUX-NOT: "--export-dynamic" +// CHECK-SHARED-HWASAN-AARCH64-LINUX-NOT: "--dynamic-list" + +// RUN: %clang -no-canonical-prefixes %s -### -o %t.so -shared 2>&1 \ +// RUN: -target aarch64-unknown-linux -fuse-ld=ld -fsanitize=hwaddress \ +// RUN: -shared-libsan -resource-dir=%S/Inputs/resource_dir \ +// RUN: --sysroot=%S/Inputs/basic_linux_tree \ +// RUN: | FileCheck --check-prefix=CHECK-DSO-SHARED-HWASAN-AARCH64-LINUX %s +// +// CHECK-DSO-SHARED-HWASAN-AARCH64-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}" +// CHECK-DSO_SHARED-HWASAN-AARCH64-LINUX: "-pie" +// CHECK-DSO-SHARED-HWASAN-AARCH64-LINUX-NOT: "-lc" +// CHECK-DSO-SHARED-HWASAN-AARCH64-LINUX: libclang_rt.hwasan-aarch64.so" +// CHECK-DSO-SHARED-HWASAN-AARCH64-LINUX-NOT: "-lpthread" +// CHECK-DSO-SHARED-HWASAN-AARCH64-LINUX-NOT: "-lrt" +// CHECK-DSO-SHARED-HWASAN-AARCH64-LINUX-NOT: "-ldl" +// CHECK-DSO-SHARED-HWASAN-AARCH64-LINUX-NOT: "--export-dynamic" +// CHECK-DSO-SHARED-HWASAN-AARCH64-LINUX-NOT: "--dynamic-list"