[PATCH] D37656: [cfi] Set function attributes for __cfi_* functions.
eugenis updated this revision to Diff 116618. eugenis added a comment. Switched to SetLLVMFunctionAttributes https://reviews.llvm.org/D37656 Files: clang/lib/CodeGen/CGExpr.cpp clang/test/CodeGen/cfi-check-thumb.c llvm/lib/Transforms/IPO/CrossDSOCFI.cpp llvm/test/Transforms/CrossDSOCFI/thumb.ll Index: llvm/test/Transforms/CrossDSOCFI/thumb.ll === --- llvm/test/Transforms/CrossDSOCFI/thumb.ll +++ /dev/null @@ -1,22 +0,0 @@ -; RUN: opt -mtriple=armv7-linux-android -S -cross-dso-cfi < %s | FileCheck --check-prefix=THUMB %s -; RUN: opt -mtriple=thumbv7-linux-android -S -cross-dso-cfi < %s | FileCheck --check-prefix=THUMB %s -; RUN: opt -mtriple=i386-linux -S -cross-dso-cfi < %s | FileCheck --check-prefix=NOTHUMB %s -; RUN: opt -mtriple=x86_64-linux -S -cross-dso-cfi < %s | FileCheck --check-prefix=NOTHUMB %s - -target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64" - -define signext i8 @f() !type !0 !type !1 { -entry: - ret i8 1 -} - -!llvm.module.flags = !{!2} - -!0 = !{i64 0, !"_ZTSFcvE"} -!1 = !{i64 0, i64 111} -!2 = !{i32 4, !"Cross-DSO CFI", i32 1} - -; THUMB: define void @__cfi_check({{.*}} #[[A:.*]] align 4096 -; THUMB: attributes #[[A]] = { {{.*}}"target-features"="+thumb-mode" - -; NOTHUMB: define void @__cfi_check({{.*}} align 4096 Index: llvm/lib/Transforms/IPO/CrossDSOCFI.cpp === --- llvm/lib/Transforms/IPO/CrossDSOCFI.cpp +++ llvm/lib/Transforms/IPO/CrossDSOCFI.cpp @@ -117,10 +117,6 @@ F->deleteBody(); F->setAlignment(4096); - Triple T(M.getTargetTriple()); - if (T.isARM() || T.isThumb()) -F->addFnAttr("target-features", "+thumb-mode"); - auto args = F->arg_begin(); Value &CallSiteTypeId = *(args++); CallSiteTypeId.setName("CallSiteTypeId"); Index: clang/test/CodeGen/cfi-check-thumb.c === --- /dev/null +++ clang/test/CodeGen/cfi-check-thumb.c @@ -0,0 +1,18 @@ +// Test that __cfi_check and __cfi_check_fail have common attributes and calling convention. +// Also __cfi_check is always using Thumb encoding. +// RUN: %clang_cc1 -triple armv7-linux-android -O0 -fsanitize-cfi-cross-dso \ +// RUN: -fsanitize=cfi-vcall \ +// RUN: -emit-llvm -o - %s | FileCheck --check-prefixes=CHECK,CHECK-ARM %s +// +// RUN: %clang_cc1 -triple thumbv7-linux-android -O0 -fsanitize-cfi-cross-dso \ +// RUN: -fsanitize=cfi-vcall \ +// RUN: -emit-llvm -o - %s | FileCheck --check-prefixes=CHECK,CHECK-THUMB %s +// +// REQUIRES: arm-registered-target + +// CHECK-ARM: define weak_odr hidden void @__cfi_check_fail(i8*, i8*) #[[ARM:.*]] { +// CHECK-THUMB: define weak_odr hidden void @__cfi_check_fail(i8*, i8*) #[[THUMB:.*]] { +// CHECK: define weak void @__cfi_check(i64, i8*, i8*) #[[THUMB:.*]] { + +// CHECK-ARM: attributes #[[ARM]] = {{.*}}"target-features"="{{.*}}-thumb-mode +// CHECK: attributes #[[THUMB]] = {{.*}}"target-features"="{{.*}}+thumb-mode Index: clang/lib/CodeGen/CGExpr.cpp === --- clang/lib/CodeGen/CGExpr.cpp +++ clang/lib/CodeGen/CGExpr.cpp @@ -2928,6 +2928,18 @@ llvm::CallInst::Create( llvm::Intrinsic::getDeclaration(M, llvm::Intrinsic::trap), "", BB); llvm::ReturnInst::Create(Ctx, nullptr, BB); + + // Set default function attributes, but force thumb encoding if applicable. + const CGFunctionInfo &FI = + CGM.getTypes().arrangeBuiltinFunctionDeclaration(getContext().VoidTy, {}); + FunctionDecl *FD = + FunctionDecl::Create(getContext(), getContext().getTranslationUnitDecl(), + {}, {}, {}, getContext().VoidTy, nullptr, SC_Extern); + const auto &Triple = getTarget().getTriple(); + if (Triple.isARM() || Triple.isThumb()) { +FD->addAttr(TargetAttr::CreateImplicit(getContext(), "thumb")); + } + CGM.SetLLVMFunctionAttributes(FD, FI, F); } // This function is basically a switch over the CFI failure kind, which is @@ -3011,6 +3023,9 @@ } FinishFunction(); + + CGM.SetLLVMFunctionAttributes(nullptr, FI, F); + // The only reference to this function will be created during LTO link. // Make sure it survives until then. CGM.addUsedGlobal(F); Index: llvm/test/Transforms/CrossDSOCFI/thumb.ll === --- llvm/test/Transforms/CrossDSOCFI/thumb.ll +++ /dev/null @@ -1,22 +0,0 @@ -; RUN: opt -mtriple=armv7-linux-android -S -cross-dso-cfi < %s | FileCheck --check-prefix=THUMB %s -; RUN: opt -mtriple=thumbv7-linux-android -S -cross-dso-cfi < %s | FileCheck --check-prefix=THUMB %s -; RUN: opt -mtriple=i386-linux -S -cross-dso-cfi < %s | FileCheck --check-prefix=NOTHUMB %s -; RUN: opt -mtriple=x86_64-linux -S -cross-dso-cfi < %s | FileCheck --check-prefix=NOTHUMB %s - -target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64" - -define signext i8 @f() !type !0
[PATCH] D38430: Enable -pie and --enable-new-dtags by default on Android.
eugenis created this revision. Also enable -no-pie on Gnu toolchain (previously available on Darwin only). Non-PIE executables won't even start on recent Android, and DT_RPATH is ignored by the loader. https://reviews.llvm.org/D38430 Files: clang/lib/Driver/SanitizerArgs.cpp clang/lib/Driver/ToolChains/Gnu.cpp clang/lib/Driver/ToolChains/Linux.cpp clang/test/Driver/android-pie.c clang/test/Driver/fsanitize.c clang/test/Driver/linux-ld.c clang/test/Driver/pic.c clang/test/Driver/sanitizer-ld.c Index: clang/test/Driver/sanitizer-ld.c === --- clang/test/Driver/sanitizer-ld.c +++ clang/test/Driver/sanitizer-ld.c @@ -127,7 +127,7 @@ // // CHECK-ASAN-ANDROID: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}" // CHECK-ASAN-ANDROID-NOT: "-lc" -// CHECK-ASAN-ANDROID: "-pie" +// CHECK-ASAN-ANDROID-NOT: "-pie" // CHECK-ASAN-ANDROID-NOT: "-lpthread" // CHECK-ASAN-ANDROID: libclang_rt.asan-arm-android.so" // CHECK-ASAN-ANDROID-NOT: "-lpthread" @@ -139,7 +139,7 @@ // // CHECK-ASAN-ANDROID-X86: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}" // CHECK-ASAN-ANDROID-X86-NOT: "-lc" -// CHECK-ASAN-ANDROID-X86: "-pie" +// CHECK-ASAN-ANDROID-X86-NOT: "-pie" // CHECK-ASAN-ANDROID-X86-NOT: "-lpthread" // CHECK-ASAN-ANDROID-X86: libclang_rt.asan-i686-android.so" // CHECK-ASAN-ANDROID-X86-NOT: "-lpthread" Index: clang/test/Driver/pic.c === --- clang/test/Driver/pic.c +++ clang/test/Driver/pic.c @@ -251,17 +251,54 @@ // RUN: %clang %s -target i386-pc-openbsd -no-pie -### 2>&1 \ // RUN: | FileCheck %s --check-prefix=CHECK-NOPIE-LD // -// On Android PIC is enabled by default +// On Android PIC is enabled by default, and PIE is enabled by default starting +// with API16. // RUN: %clang -c %s -target i686-linux-android -### 2>&1 \ // RUN: | FileCheck %s --check-prefix=CHECK-PIC2 +// RUN: %clang -c %s -target i686-linux-android14 -### 2>&1 \ +// RUN: | FileCheck %s --check-prefix=CHECK-PIC2 +// RUN: %clang -c %s -target i686-linux-android16 -### 2>&1 \ +// RUN: | FileCheck %s --check-prefix=CHECK-PIE2 +// RUN: %clang -c %s -target i686-linux-android24 -### 2>&1 \ +// RUN: | FileCheck %s --check-prefix=CHECK-PIE2 +// // RUN: %clang -c %s -target arm-linux-androideabi -### 2>&1 \ // RUN: | FileCheck %s --check-prefix=CHECK-PIC1 +// RUN: %clang -c %s -target arm-linux-androideabi14 -### 2>&1 \ +// RUN: | FileCheck %s --check-prefix=CHECK-PIC1 +// RUN: %clang -c %s -target arm-linux-androideabi16 -### 2>&1 \ +// RUN: | FileCheck %s --check-prefix=CHECK-PIE2 +// RUN: %clang -c %s -target arm-linux-androideabi24 -### 2>&1 \ +// RUN: | FileCheck %s --check-prefix=CHECK-PIE2 +// // RUN: %clang -c %s -target mipsel-linux-android -### 2>&1 \ // RUN: | FileCheck %s --check-prefix=CHECK-PIC1 -// RUN: %clang -c %s -target aarch64-linux-android -### 2>&1 \ +// RUN: %clang -c %s -target mipsel-linux-android14 -### 2>&1 \ // RUN: | FileCheck %s --check-prefix=CHECK-PIC1 +// RUN: %clang -c %s -target mipsel-linux-android16 -### 2>&1 \ +// RUN: | FileCheck %s --check-prefix=CHECK-PIE2 +// RUN: %clang -c %s -target mipsel-linux-android24 -### 2>&1 \ +// RUN: | FileCheck %s --check-prefix=CHECK-PIE2 +// +// 64-bit Android targets are always PIE. +// RUN: %clang -c %s -target aarch64-linux-android -### 2>&1 \ +// RUN: | FileCheck %s --check-prefix=CHECK-PIE2 +// RUN: %clang -c %s -target aarch64-linux-android24 -### 2>&1 \ +// RUN: | FileCheck %s --check-prefix=CHECK-PIE2 // RUN: %clang -c %s -target arm64-linux-android -### 2>&1 \ -// RUN: | FileCheck %s --check-prefix=CHECK-PIC1 +// RUN: | FileCheck %s --check-prefix=CHECK-PIE2 +// +// Default value of PIE can be overwritten, even on 64-bit targets. +// RUN: %clang -c %s -target arm-linux-androideabi -fPIE -### 2>&1 \ +// RUN: | FileCheck %s --check-prefix=CHECK-PIE2 +// RUN: %clang -c %s -target i686-linux-android14 -fPIE -### 2>&1 \ +// RUN: | FileCheck %s --check-prefix=CHECK-PIE2 +// RUN: %clang -c %s -target i686-linux-android16 -fno-PIE -### 2>&1 \ +// RUN: | FileCheck %s --check-prefix=CHECK-NO-PIC +// RUN: %clang -c %s -target aarch64-linux-android -fno-PIE -### 2>&1 \ +// RUN: | FileCheck %s --check-prefix=CHECK-NO-PIC +// RUN: %clang -c %s -target aarch64-linux-android24 -fno-PIE -### 2>&1 \ +// RUN: | FileCheck %s --check-prefix=CHECK-NO-PIC // // On Windows-X64 PIC is enabled by default // RUN: %clang -c %s -target x86_64-pc-windows-msvc18.0.0 -### 2>&1 \ Index: clang/test/Driver/linux-ld.c === --- clang/test/Driver/linux-ld.c +++ clang/test/Driver/linux-ld.c @@ -1133,6 +1133,7 @@ // RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \ // RUN: | FileCheck --check-prefix=CHECK-ANDROID %s // CHECK-ANDROID: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" +// CHECK-ANDROID: "--enable-new-dtags" // CHECK-ANDROID: "{{.*}}{{/|
[PATCH] D38525: Cleanup and generalize -shared-libasan.
eugenis created this revision. Herald added a subscriber: srhines. - Add -static-libasan for targets that default to shared. - Remove an Android special case. It is now possible (but untested) to use static compiler-rt libraries there. - Support libclang_rt.ubsan_standalone as a shared library. Unlike GCC, this change applies -shared-libasan / -static-libasan to all sanitizers. I don't see a point in multiple flags like -shared-libubsan, considering that most sanitizers are not compatible with each other, and each link has basically a single shared/static choice. https://reviews.llvm.org/D38525 Files: clang/include/clang/Driver/Options.td clang/include/clang/Driver/SanitizerArgs.h clang/lib/Driver/SanitizerArgs.cpp clang/lib/Driver/ToolChains/CommonArgs.cpp clang/lib/Driver/ToolChains/Fuchsia.cpp clang/lib/Driver/ToolChains/MSVC.cpp clang/test/Driver/sanitizer-ld.c Index: clang/test/Driver/sanitizer-ld.c === --- clang/test/Driver/sanitizer-ld.c +++ clang/test/Driver/sanitizer-ld.c @@ -131,6 +131,39 @@ // CHECK-ASAN-ANDROID-NOT: "-lpthread" // CHECK-ASAN-ANDROID: libclang_rt.asan-arm-android.so" // CHECK-ASAN-ANDROID-NOT: "-lpthread" + +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -target arm-linux-androideabi -fuse-ld=ld -fsanitize=address \ +// RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \ +// RUN: -static-libasan \ +// RUN: | FileCheck --check-prefix=CHECK-ASAN-ANDROID-STATICLIBASAN %s +// +// CHECK-ASAN-ANDROID-STATICLIBASAN: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}" +// CHECK-ASAN-ANDROID-STATICLIBASAN: libclang_rt.asan-arm-android.a" +// CHECK-ASAN-ANDROID-STATICLIBASAN: "-lpthread" + +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -target arm-linux-androideabi -fuse-ld=ld -fsanitize=undefined \ +// RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \ +// RUN: | FileCheck --check-prefix=CHECK-UBSAN-ANDROID %s +// +// CHECK-UBSAN-ANDROID: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}" +// CHECK-UBSAN-ANDROID-NOT: "-lc" +// CHECK-UBSAN-ANDROID-NOT: "-pie" +// CHECK-UBSAN-ANDROID-NOT: "-lpthread" +// CHECK-UBSAN-ANDROID: libclang_rt.ubsan_standalone-arm-android.so" +// CHECK-UBSAN-ANDROID-NOT: "-lpthread" + +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -target arm-linux-androideabi -fuse-ld=ld -fsanitize=undefined \ +// RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \ +// RUN: -static-libasan \ +// RUN: | FileCheck --check-prefix=CHECK-UBSAN-ANDROID-STATICLIBASAN %s +// +// CHECK-UBSAN-ANDROID-STATICLIBASAN: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}" +// CHECK-UBSAN-ANDROID-STATICLIBASAN: libclang_rt.ubsan_standalone-arm-android.a" +// CHECK-UBSAN-ANDROID-STATICLIBASAN: "-lpthread" + // // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: -target i686-linux-android -fuse-ld=ld -fsanitize=address \ @@ -214,6 +247,13 @@ // RUN: -target i386-unknown-linux -fuse-ld=ld \ // RUN: --sysroot=%S/Inputs/basic_linux_tree \ // RUN: | FileCheck --check-prefix=CHECK-UBSAN-LINUX %s + +// RUN: %clang -fsanitize=undefined %s -### -o %t.o 2>&1 \ +// RUN: -target i386-unknown-linux -fuse-ld=ld \ +// RUN: --sysroot=%S/Inputs/basic_linux_tree \ +// RUN: -static-libasan \ +// RUN: | FileCheck --check-prefix=CHECK-UBSAN-LINUX %s + // CHECK-UBSAN-LINUX: "{{.*}}ld{{(.exe)?}}" // CHECK-UBSAN-LINUX-NOT: libclang_rt.asan // CHECK-UBSAN-LINUX-NOT: libclang_rt.ubsan_standalone_cxx @@ -223,6 +263,27 @@ // CHECK-UBSAN-LINUX-NOT: "-lstdc++" // CHECK-UBSAN-LINUX: "-lpthread" +// RUN: %clang -fsanitize=undefined %s -### -o %t.o 2>&1 \ +// RUN: -target i386-unknown-linux -fuse-ld=ld \ +// RUN: --sysroot=%S/Inputs/basic_linux_tree \ +// RUN: -shared-libasan \ +// RUN: | FileCheck --check-prefix=CHECK-UBSAN-LINUX-SHAREDLIBASAN %s + +// RUN: %clang -fsanitize=undefined %s -### -o %t.o 2>&1 \ +// RUN: -target i386-unknown-linux -fuse-ld=ld \ +// RUN: --sysroot=%S/Inputs/basic_linux_tree \ +// RUN: -static-libasan -shared-libasan \ +// RUN: | FileCheck --check-prefix=CHECK-UBSAN-LINUX-SHAREDLIBASAN %s + +// RUN: %clang -fsanitize=undefined %s -### -o %t.o 2>&1 \ +// RUN: -target i386-unknown-linux -fuse-ld=ld \ +// RUN: --sysroot=%S/Inputs/basic_linux_tree \ +// RUN: -shared -shared-libasan \ +// RUN: | FileCheck --check-prefix=CHECK-UBSAN-LINUX-SHAREDLIBASAN %s + +// CHECK-UBSAN-LINUX-SHAREDLIBASAN: "{{.*}}ld{{(.exe)?}}" +// CHECK-UBSAN-LINUX-SHAREDLIBASAN: "{{.*}}libclang_rt.ubsan_standalone-i386.so{{.*}}" + // RUN: %clang -fsanitize=undefined -fsanitize-link-c++-runtime %s -### -o %t.o 2>&1 \ // RUN: -target i386-unknown-linux \ // RUN: --sysroot=%S/Inputs/basic_linux_tree \ Index: clang/lib/Driver/ToolChains/MSVC.cpp === --- clang/lib/Driver/ToolChains/MSVC.cpp +++ clang/l
[PATCH] D38430: Enable -pie and --enable-new-dtags by default on Android.
eugenis added a comment. ping https://reviews.llvm.org/D38430 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38525: Cleanup and generalize -shared-libasan.
eugenis updated this revision to Diff 117767. eugenis added a comment. renamed flags to *-libsan https://reviews.llvm.org/D38525 Files: clang/include/clang/Driver/Options.td clang/include/clang/Driver/SanitizerArgs.h clang/lib/Driver/SanitizerArgs.cpp clang/lib/Driver/ToolChains/CommonArgs.cpp clang/lib/Driver/ToolChains/Fuchsia.cpp clang/lib/Driver/ToolChains/MSVC.cpp clang/test/Driver/sanitizer-ld.c Index: clang/test/Driver/sanitizer-ld.c === --- clang/test/Driver/sanitizer-ld.c +++ clang/test/Driver/sanitizer-ld.c @@ -16,11 +16,24 @@ // CHECK-ASAN-LINUX: "-lrt" // CHECK-ASAN-LINUX: "-ldl" +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -target i386-unknown-linux -fuse-ld=ld -fsanitize=address -shared-libsan \ +// RUN: -resource-dir=%S/Inputs/resource_dir \ +// RUN: --sysroot=%S/Inputs/basic_linux_tree \ +// RUN: | FileCheck --check-prefix=CHECK-SHARED-ASAN-LINUX %s + // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: -target i386-unknown-linux -fuse-ld=ld -fsanitize=address -shared-libasan \ // RUN: -resource-dir=%S/Inputs/resource_dir \ // RUN: --sysroot=%S/Inputs/basic_linux_tree \ // RUN: | FileCheck --check-prefix=CHECK-SHARED-ASAN-LINUX %s + +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -target i386-unknown-linux -fuse-ld=ld -fsanitize=address \ +// RUN: -shared-libsan -static-libsan -shared-libasan \ +// RUN: -resource-dir=%S/Inputs/resource_dir \ +// RUN: --sysroot=%S/Inputs/basic_linux_tree \ +// RUN: | FileCheck --check-prefix=CHECK-SHARED-ASAN-LINUX %s // // CHECK-SHARED-ASAN-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}" // CHECK-SHARED-ASAN-LINUX-NOT: "-lc" @@ -34,7 +47,7 @@ // CHECK-SHARED-ASAN-LINUX-NOT: "--dynamic-list" // RUN: %clang -no-canonical-prefixes %s -### -o %t.so -shared 2>&1 \ -// RUN: -target i386-unknown-linux -fuse-ld=ld -fsanitize=address -shared-libasan \ +// RUN: -target i386-unknown-linux -fuse-ld=ld -fsanitize=address -shared-libsan \ // RUN: -resource-dir=%S/Inputs/resource_dir \ // RUN: --sysroot=%S/Inputs/basic_linux_tree \ // RUN: | FileCheck --check-prefix=CHECK-DSO-SHARED-ASAN-LINUX %s @@ -131,6 +144,39 @@ // CHECK-ASAN-ANDROID-NOT: "-lpthread" // CHECK-ASAN-ANDROID: libclang_rt.asan-arm-android.so" // CHECK-ASAN-ANDROID-NOT: "-lpthread" + +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -target arm-linux-androideabi -fuse-ld=ld -fsanitize=address \ +// RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \ +// RUN: -static-libsan \ +// RUN: | FileCheck --check-prefix=CHECK-ASAN-ANDROID-STATICLIBASAN %s +// +// CHECK-ASAN-ANDROID-STATICLIBASAN: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}" +// CHECK-ASAN-ANDROID-STATICLIBASAN: libclang_rt.asan-arm-android.a" +// CHECK-ASAN-ANDROID-STATICLIBASAN: "-lpthread" + +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -target arm-linux-androideabi -fuse-ld=ld -fsanitize=undefined \ +// RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \ +// RUN: | FileCheck --check-prefix=CHECK-UBSAN-ANDROID %s +// +// CHECK-UBSAN-ANDROID: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}" +// CHECK-UBSAN-ANDROID-NOT: "-lc" +// CHECK-UBSAN-ANDROID-NOT: "-pie" +// CHECK-UBSAN-ANDROID-NOT: "-lpthread" +// CHECK-UBSAN-ANDROID: libclang_rt.ubsan_standalone-arm-android.so" +// CHECK-UBSAN-ANDROID-NOT: "-lpthread" + +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -target arm-linux-androideabi -fuse-ld=ld -fsanitize=undefined \ +// RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \ +// RUN: -static-libsan \ +// RUN: | FileCheck --check-prefix=CHECK-UBSAN-ANDROID-STATICLIBASAN %s +// +// CHECK-UBSAN-ANDROID-STATICLIBASAN: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}" +// CHECK-UBSAN-ANDROID-STATICLIBASAN: libclang_rt.ubsan_standalone-arm-android.a" +// CHECK-UBSAN-ANDROID-STATICLIBASAN: "-lpthread" + // // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: -target i686-linux-android -fuse-ld=ld -fsanitize=address \ @@ -147,10 +193,10 @@ // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: -target arm-linux-androideabi -fsanitize=address \ // RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \ -// RUN: -shared-libasan \ +// RUN: -shared-libsan \ // RUN: | FileCheck --check-prefix=CHECK-ASAN-ANDROID-SHARED-LIBASAN %s // -// CHECK-ASAN-ANDROID-SHARED-LIBASAN-NOT: argument unused during compilation: '-shared-libasan' +// CHECK-ASAN-ANDROID-SHARED-LIBASAN-NOT: argument unused during compilation: '-shared-libsan' // // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: -target arm-linux-androideabi -fuse-ld=ld -fsanitize=address \ @@ -214,6 +260,13 @@ // RUN: -target i386-unknown-linux -fuse-ld=ld \ // RUN: --sysroot=%S/Inputs/basic_linu
[PATCH] D38525: Cleanup and generalize -shared-libasan.
eugenis added inline comments. Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:563 +if (SanArgs.needsUbsanRt()) { + if (SanArgs.requiresMinimalRuntime()) { +SharedRuntimes.push_back("ubsan_minimal"); vitalybuka wrote: > Shouldn't ubsan changes be in the separate patch? They are quite hard to separate, and without ubsan there is not much point to this change. https://reviews.llvm.org/D38525 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38525: Cleanup and generalize -shared-libasan.
eugenis updated this revision to Diff 117875. eugenis added a comment. address comment https://reviews.llvm.org/D38525 Files: clang/include/clang/Driver/Options.td clang/include/clang/Driver/SanitizerArgs.h clang/lib/Driver/SanitizerArgs.cpp clang/lib/Driver/ToolChains/CommonArgs.cpp clang/lib/Driver/ToolChains/Fuchsia.cpp clang/lib/Driver/ToolChains/MSVC.cpp clang/test/Driver/sanitizer-ld.c Index: clang/test/Driver/sanitizer-ld.c === --- clang/test/Driver/sanitizer-ld.c +++ clang/test/Driver/sanitizer-ld.c @@ -16,11 +16,24 @@ // CHECK-ASAN-LINUX: "-lrt" // CHECK-ASAN-LINUX: "-ldl" +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -target i386-unknown-linux -fuse-ld=ld -fsanitize=address -shared-libsan \ +// RUN: -resource-dir=%S/Inputs/resource_dir \ +// RUN: --sysroot=%S/Inputs/basic_linux_tree \ +// RUN: | FileCheck --check-prefix=CHECK-SHARED-ASAN-LINUX %s + // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: -target i386-unknown-linux -fuse-ld=ld -fsanitize=address -shared-libasan \ // RUN: -resource-dir=%S/Inputs/resource_dir \ // RUN: --sysroot=%S/Inputs/basic_linux_tree \ // RUN: | FileCheck --check-prefix=CHECK-SHARED-ASAN-LINUX %s + +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -target i386-unknown-linux -fuse-ld=ld -fsanitize=address \ +// RUN: -shared-libsan -static-libsan -shared-libasan \ +// RUN: -resource-dir=%S/Inputs/resource_dir \ +// RUN: --sysroot=%S/Inputs/basic_linux_tree \ +// RUN: | FileCheck --check-prefix=CHECK-SHARED-ASAN-LINUX %s // // CHECK-SHARED-ASAN-LINUX: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}" // CHECK-SHARED-ASAN-LINUX-NOT: "-lc" @@ -34,7 +47,7 @@ // CHECK-SHARED-ASAN-LINUX-NOT: "--dynamic-list" // RUN: %clang -no-canonical-prefixes %s -### -o %t.so -shared 2>&1 \ -// RUN: -target i386-unknown-linux -fuse-ld=ld -fsanitize=address -shared-libasan \ +// RUN: -target i386-unknown-linux -fuse-ld=ld -fsanitize=address -shared-libsan \ // RUN: -resource-dir=%S/Inputs/resource_dir \ // RUN: --sysroot=%S/Inputs/basic_linux_tree \ // RUN: | FileCheck --check-prefix=CHECK-DSO-SHARED-ASAN-LINUX %s @@ -131,6 +144,39 @@ // CHECK-ASAN-ANDROID-NOT: "-lpthread" // CHECK-ASAN-ANDROID: libclang_rt.asan-arm-android.so" // CHECK-ASAN-ANDROID-NOT: "-lpthread" + +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -target arm-linux-androideabi -fuse-ld=ld -fsanitize=address \ +// RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \ +// RUN: -static-libsan \ +// RUN: | FileCheck --check-prefix=CHECK-ASAN-ANDROID-STATICLIBASAN %s +// +// CHECK-ASAN-ANDROID-STATICLIBASAN: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}" +// CHECK-ASAN-ANDROID-STATICLIBASAN: libclang_rt.asan-arm-android.a" +// CHECK-ASAN-ANDROID-STATICLIBASAN: "-lpthread" + +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -target arm-linux-androideabi -fuse-ld=ld -fsanitize=undefined \ +// RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \ +// RUN: | FileCheck --check-prefix=CHECK-UBSAN-ANDROID %s +// +// CHECK-UBSAN-ANDROID: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}" +// CHECK-UBSAN-ANDROID-NOT: "-lc" +// CHECK-UBSAN-ANDROID-NOT: "-pie" +// CHECK-UBSAN-ANDROID-NOT: "-lpthread" +// CHECK-UBSAN-ANDROID: libclang_rt.ubsan_standalone-arm-android.so" +// CHECK-UBSAN-ANDROID-NOT: "-lpthread" + +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -target arm-linux-androideabi -fuse-ld=ld -fsanitize=undefined \ +// RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \ +// RUN: -static-libsan \ +// RUN: | FileCheck --check-prefix=CHECK-UBSAN-ANDROID-STATICLIBASAN %s +// +// CHECK-UBSAN-ANDROID-STATICLIBASAN: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}" +// CHECK-UBSAN-ANDROID-STATICLIBASAN: libclang_rt.ubsan_standalone-arm-android.a" +// CHECK-UBSAN-ANDROID-STATICLIBASAN: "-lpthread" + // // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: -target i686-linux-android -fuse-ld=ld -fsanitize=address \ @@ -147,10 +193,10 @@ // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: -target arm-linux-androideabi -fsanitize=address \ // RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \ -// RUN: -shared-libasan \ +// RUN: -shared-libsan \ // RUN: | FileCheck --check-prefix=CHECK-ASAN-ANDROID-SHARED-LIBASAN %s // -// CHECK-ASAN-ANDROID-SHARED-LIBASAN-NOT: argument unused during compilation: '-shared-libasan' +// CHECK-ASAN-ANDROID-SHARED-LIBASAN-NOT: argument unused during compilation: '-shared-libsan' // // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: -target arm-linux-androideabi -fuse-ld=ld -fsanitize=address \ @@ -214,6 +260,13 @@ // RUN: -target i386-unknown-linux -fuse-ld=ld \ // RUN: --sysroot=%S/Inputs/basic_linux_tree \
[PATCH] D38525: Cleanup and generalize -shared-libasan.
eugenis added inline comments. Comment at: clang/lib/Driver/SanitizerArgs.cpp:614 + if (Arg *A = Args.getLastArg(options::OPT_shared_libsan, + options::OPT_static_libsan)) +SharedRuntime = A->getOption().matches(options::OPT_shared_libsan); vitalybuka wrote: > ``` > SharedRuntime = Args.hasFlag(options::OPT_shared_libsan,, > options::OPT_static_libsan, > TC.getTriple().isAndroid() || > TC.getTriple().isOSFuchsia()); > ``` good! https://reviews.llvm.org/D38525 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38525: Cleanup and generalize -shared-libasan.
This revision was automatically updated to reflect the committed changes. Closed by commit rL315015: Cleanup and generalize -shared-libasan. (authored by eugenis). Changed prior to commit: https://reviews.llvm.org/D38525?vs=117875&id=117878#toc Repository: rL LLVM https://reviews.llvm.org/D38525 Files: cfe/trunk/include/clang/Driver/Options.td cfe/trunk/include/clang/Driver/SanitizerArgs.h cfe/trunk/lib/Driver/SanitizerArgs.cpp cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp cfe/trunk/lib/Driver/ToolChains/MSVC.cpp cfe/trunk/test/Driver/sanitizer-ld.c Index: cfe/trunk/lib/Driver/SanitizerArgs.cpp === --- cfe/trunk/lib/Driver/SanitizerArgs.cpp +++ cfe/trunk/lib/Driver/SanitizerArgs.cpp @@ -610,10 +610,11 @@ CoverageFeatures |= CoverageFunc; } + SharedRuntime = + Args.hasFlag(options::OPT_shared_libsan, options::OPT_static_libsan, + TC.getTriple().isAndroid() || TC.getTriple().isOSFuchsia()); + if (AllAddedKinds & Address) { -AsanSharedRuntime = -Args.hasArg(options::OPT_shared_libasan) || -TC.getTriple().isAndroid() || TC.getTriple().isOSFuchsia(); NeedPIE |= TC.getTriple().isAndroid() || TC.getTriple().isOSFuchsia(); if (Arg *A = Args.getLastArg(options::OPT_fsanitize_address_field_padding)) { Index: cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp === --- cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp +++ cfe/trunk/lib/Driver/ToolChains/Fuchsia.cpp @@ -81,7 +81,7 @@ if (!Args.hasArg(options::OPT_shared)) { std::string Dyld = D.DyldPrefix; if (ToolChain.getSanitizerArgs().needsAsanRt() && -ToolChain.getSanitizerArgs().needsSharedAsanRt()) +ToolChain.getSanitizerArgs().needsSharedRt()) Dyld += "asan/"; Dyld += "ld.so.1"; CmdArgs.push_back("-dynamic-linker"); Index: cfe/trunk/lib/Driver/ToolChains/MSVC.cpp === --- cfe/trunk/lib/Driver/ToolChains/MSVC.cpp +++ cfe/trunk/lib/Driver/ToolChains/MSVC.cpp @@ -375,7 +375,7 @@ if (TC.getSanitizerArgs().needsAsanRt()) { CmdArgs.push_back(Args.MakeArgString("-debug")); CmdArgs.push_back(Args.MakeArgString("-incremental:no")); -if (TC.getSanitizerArgs().needsSharedAsanRt() || +if (TC.getSanitizerArgs().needsSharedRt() || Args.hasArg(options::OPT__SLASH_MD, options::OPT__SLASH_MDd)) { for (const auto &Lib : {"asan_dynamic", "asan_dynamic_runtime_thunk"}) CmdArgs.push_back(TC.getCompilerRTArgString(Args, Lib)); Index: cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp === --- cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp +++ cfe/trunk/lib/Driver/ToolChains/CommonArgs.cpp @@ -560,27 +560,35 @@ SmallVectorImpl &RequiredSymbols) { const SanitizerArgs &SanArgs = TC.getSanitizerArgs(); // Collect shared runtimes. - if (SanArgs.needsAsanRt() && SanArgs.needsSharedAsanRt()) { -SharedRuntimes.push_back("asan"); + if (SanArgs.needsSharedRt()) { +if (SanArgs.needsAsanRt()) { + SharedRuntimes.push_back("asan"); + if (!Args.hasArg(options::OPT_shared) && !TC.getTriple().isAndroid()) +HelperStaticRuntimes.push_back("asan-preinit"); +} + +if (SanArgs.needsUbsanRt()) { + if (SanArgs.requiresMinimalRuntime()) { +SharedRuntimes.push_back("ubsan_minimal"); + } else { +SharedRuntimes.push_back("ubsan_standalone"); + } +} } // The stats_client library is also statically linked into DSOs. if (SanArgs.needsStatsRt()) StaticRuntimes.push_back("stats_client"); // Collect static runtimes. - if (Args.hasArg(options::OPT_shared) || TC.getTriple().isAndroid()) { -// Don't link static runtimes into DSOs or if compiling for Android. + if (Args.hasArg(options::OPT_shared) || SanArgs.needsSharedRt()) { +// Don't link static runtimes into DSOs or if -shared-libasan. return; } if (SanArgs.needsAsanRt()) { -if (SanArgs.needsSharedAsanRt()) { - HelperStaticRuntimes.push_back("asan-preinit"); -} else { - StaticRuntimes.push_back("asan"); - if (SanArgs.linkCXXRuntimes()) -StaticRuntimes.push_back("asan_cxx"); -} +StaticRuntimes.push_back("asan"); +if (SanArgs.linkCXXRuntimes()) + StaticRuntimes.push_back("asan_cxx"); } if (SanArgs.needsDfsanRt()) StaticRuntimes.push_back("dfsan"); Index: cfe/trunk/include/clang/Driver/SanitizerArgs.h === --- cfe/trunk/include/clang/Driver/SanitizerArgs.h +++ cfe/trunk/include/clang/Driver/SanitizerArgs.h @@ -33,7 +33,7 @@ bool MsanUseAfterDtor = false; bool CfiCrossDso = false; int AsanFieldPadding = 0; - bool AsanSharedRuntim
[PATCH] D38430: Enable -pie and --enable-new-dtags by default on Android.
eugenis added a comment. ping https://reviews.llvm.org/D38430 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38908: Do not link clang_rt.cfi on Android.
eugenis created this revision. Herald added a subscriber: srhines. The OS provides cross-dso CFI support starting with Android O. Trapping mode does not require any runtime at all, and diagnostic mode requires just ubsan-standalone. https://reviews.llvm.org/D38908 Files: clang/include/clang/Driver/SanitizerArgs.h clang/lib/Driver/SanitizerArgs.cpp clang/test/Driver/sanitizer-ld.c Index: clang/test/Driver/sanitizer-ld.c === --- clang/test/Driver/sanitizer-ld.c +++ clang/test/Driver/sanitizer-ld.c @@ -508,6 +508,24 @@ // CHECK-CFI-CROSS-DSO-DIAG-LINUX: "-whole-archive" "{{[^"]*}}libclang_rt.cfi_diag-x86_64.a" "-no-whole-archive" // CHECK-CFI-CROSS-DSO-DIAG-LINUX: -export-dynamic +// Cross-DSO CFI on Android does not link runtime libraries. +// RUN: %clang -fsanitize=cfi -fsanitize-cfi-cross-dso %s -### -o %t.o 2>&1 \ +// RUN: -target aarch64-linux-android -fuse-ld=ld \ +// RUN: --sysroot=%S/Inputs/basic_android_tree \ +// RUN: | FileCheck --check-prefix=CHECK-CFI-CROSS-DSO-ANDROID %s +// CHECK-CFI-CROSS-DSO-ANDROID: "{{.*}}ld{{(.exe)?}}" +// CHECK-CFI-CROSS-DSO-ANDROID-NOT: libclang_rt. + +// Cross-DSO CFI with diagnostics on Android links just the UBSAN runtime. +// RUN: %clang -fsanitize=cfi -fsanitize-cfi-cross-dso %s -### -o %t.o 2>&1 \ +// RUN: -fno-sanitize-trap=cfi -fsanitize-recover=cfi \ +// RUN: -target aarch64-linux-android -fuse-ld=ld \ +// RUN: --sysroot=%S/Inputs/basic_android_tree \ +// RUN: | FileCheck --check-prefix=CHECK-CFI-CROSS-DSO-DIAG-ANDROID %s +// CHECK-CFI-CROSS-DSO-DIAG-ANDROID: "{{.*}}ld{{(.exe)?}}" +// CHECK-CFI-CROSS-DSO-DIAG-ANDROID: "{{[^"]*}}libclang_rt.ubsan_standalone-aarch64-android.so" +// CHECK-CFI-CROSS-DSO-DIAG-ANDROID: "-export-dynamic-symbol=__cfi_check" + // RUN: %clangxx -fsanitize=address %s -### -o %t.o 2>&1 \ // RUN: -mmacosx-version-min=10.6 \ // RUN: -target x86_64-apple-darwin13.4.0 -fuse-ld=ld -stdlib=platform \ @@ -596,26 +614,6 @@ // CHECK-SAFESTACK-ANDROID-AARCH64: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}" // CHECK-SAFESTACK-ANDROID-AARCH64-NOT: libclang_rt.safestack -// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ -// RUN: -target arm-linux-androideabi -fuse-ld=ld -fsanitize=cfi \ -// RUN: --sysroot=%S/Inputs/basic_android_tree \ -// RUN: | FileCheck --check-prefix=CHECK-CFI-ANDROID %s -// -// CHECK-CFI-ANDROID: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}" -// CHECK-CFI-ANDROID-NOT: libclang_rt.cfi -// CHECK-CFI-ANDROID-NOT: __cfi_check - -// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ -// RUN: -target arm-linux-androideabi -fuse-ld=ld -fsanitize=cfi \ -// RUN: -fsanitize-cfi-cross-dso \ -// RUN: --sysroot=%S/Inputs/basic_android_tree \ -// RUN: | FileCheck --check-prefix=CHECK-CROSSDSO-CFI-ANDROID %s -// -// CHECK-CROSSDSO-CFI-ANDROID: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}" -// CHECK-CROSSDSO-CFI-ANDROID-NOT: libclang_rt.cfi -// CHECK-CROSSDSO-CFI-ANDROID: -export-dynamic-symbol=__cfi_check -// CHECK-CROSSDSO-CFI-ANDROID-NOT: libclang_rt.cfi - // RUN: %clang -fsanitize=undefined %s -### -o %t.o 2>&1 \ // RUN: -target x86_64-scei-ps4 -fuse-ld=ld \ // RUN: -shared \ Index: clang/lib/Driver/SanitizerArgs.cpp === --- clang/lib/Driver/SanitizerArgs.cpp +++ clang/lib/Driver/SanitizerArgs.cpp @@ -171,19 +171,23 @@ } bool SanitizerArgs::needsUbsanRt() const { - return ((Sanitizers.Mask & NeedsUbsanRt & ~TrapSanitizers.Mask) || - CoverageFeatures) && - !Sanitizers.has(Address) && !Sanitizers.has(Memory) && - !Sanitizers.has(Thread) && !Sanitizers.has(DataFlow) && - !Sanitizers.has(Leak) && !CfiCrossDso; + // All of these include ubsan. + if (needsAsanRt() || needsMsanRt() || needsTsanRt() || needsDfsanRt() || + needsLsanRt() || needsCfiDiagRt()) +return false; + + return (Sanitizers.Mask & NeedsUbsanRt & ~TrapSanitizers.Mask) || + CoverageFeatures; } bool SanitizerArgs::needsCfiRt() const { - return !(Sanitizers.Mask & CFI & ~TrapSanitizers.Mask) && CfiCrossDso; + return !(Sanitizers.Mask & CFI & ~TrapSanitizers.Mask) && CfiCrossDso && + !ImplicitCfiRuntime; } bool SanitizerArgs::needsCfiDiagRt() const { - return (Sanitizers.Mask & CFI & ~TrapSanitizers.Mask) && CfiCrossDso; + return (Sanitizers.Mask & CFI & ~TrapSanitizers.Mask) && CfiCrossDso && + !ImplicitCfiRuntime; } bool SanitizerArgs::requiresPIE() const { @@ -615,6 +619,8 @@ TC.getTriple().isAndroid() || TC.getTriple().isOSFuchsia() || TC.getTriple().isOSDarwin()); + ImplicitCfiRuntime = TC.getTriple().isAndroid(); + if (AllAddedKinds & Address) { NeedPIE |= TC.getTriple().isAndroid() || TC.getTriple().isOSFuchsia(); if (Arg *A = Index: clang/include/clang/Driver/SanitizerArgs.h =
[PATCH] D38908: Do not link clang_rt.cfi on Android.
eugenis added inline comments. Comment at: clang/test/Driver/sanitizer-ld.c:605 -// CHECK-CFI-ANDROID: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}" -// CHECK-CFI-ANDROID-NOT: libclang_rt.cfi -// CHECK-CFI-ANDROID-NOT: __cfi_check pcc wrote: > Why was this passing before? because android has NeedsSharedRt, and clang driver never adds clang_rt.cfi as a shared library. https://reviews.llvm.org/D38908 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38908: Do not link clang_rt.cfi on Android.
This revision was automatically updated to reflect the committed changes. Closed by commit rL315921: Do not link clang_rt.cfi on Android. (authored by eugenis). Changed prior to commit: https://reviews.llvm.org/D38908?vs=118986&id=119180#toc Repository: rL LLVM https://reviews.llvm.org/D38908 Files: cfe/trunk/include/clang/Driver/SanitizerArgs.h cfe/trunk/lib/Driver/SanitizerArgs.cpp cfe/trunk/test/Driver/sanitizer-ld.c Index: cfe/trunk/include/clang/Driver/SanitizerArgs.h === --- cfe/trunk/include/clang/Driver/SanitizerArgs.h +++ cfe/trunk/include/clang/Driver/SanitizerArgs.h @@ -44,6 +44,8 @@ bool TsanFuncEntryExit = true; bool TsanAtomics = true; bool MinimalRuntime = false; + // True if cross-dso CFI support if provided by the system (i.e. Android). + bool ImplicitCfiRuntime = false; public: /// Parses the sanitizer arguments from an argument list. Index: cfe/trunk/test/Driver/sanitizer-ld.c === --- cfe/trunk/test/Driver/sanitizer-ld.c +++ cfe/trunk/test/Driver/sanitizer-ld.c @@ -508,6 +508,24 @@ // CHECK-CFI-CROSS-DSO-DIAG-LINUX: "-whole-archive" "{{[^"]*}}libclang_rt.cfi_diag-x86_64.a" "-no-whole-archive" // CHECK-CFI-CROSS-DSO-DIAG-LINUX: -export-dynamic +// Cross-DSO CFI on Android does not link runtime libraries. +// RUN: %clang -fsanitize=cfi -fsanitize-cfi-cross-dso %s -### -o %t.o 2>&1 \ +// RUN: -target aarch64-linux-android -fuse-ld=ld \ +// RUN: --sysroot=%S/Inputs/basic_android_tree \ +// RUN: | FileCheck --check-prefix=CHECK-CFI-CROSS-DSO-ANDROID %s +// CHECK-CFI-CROSS-DSO-ANDROID: "{{.*}}ld{{(.exe)?}}" +// CHECK-CFI-CROSS-DSO-ANDROID-NOT: libclang_rt. + +// Cross-DSO CFI with diagnostics on Android links just the UBSAN runtime. +// RUN: %clang -fsanitize=cfi -fsanitize-cfi-cross-dso %s -### -o %t.o 2>&1 \ +// RUN: -fno-sanitize-trap=cfi -fsanitize-recover=cfi \ +// RUN: -target aarch64-linux-android -fuse-ld=ld \ +// RUN: --sysroot=%S/Inputs/basic_android_tree \ +// RUN: | FileCheck --check-prefix=CHECK-CFI-CROSS-DSO-DIAG-ANDROID %s +// CHECK-CFI-CROSS-DSO-DIAG-ANDROID: "{{.*}}ld{{(.exe)?}}" +// CHECK-CFI-CROSS-DSO-DIAG-ANDROID: "{{[^"]*}}libclang_rt.ubsan_standalone-aarch64-android.so" +// CHECK-CFI-CROSS-DSO-DIAG-ANDROID: "-export-dynamic-symbol=__cfi_check" + // RUN: %clangxx -fsanitize=address %s -### -o %t.o 2>&1 \ // RUN: -mmacosx-version-min=10.6 \ // RUN: -target x86_64-apple-darwin13.4.0 -fuse-ld=ld -stdlib=platform \ @@ -596,26 +614,6 @@ // CHECK-SAFESTACK-ANDROID-AARCH64: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}" // CHECK-SAFESTACK-ANDROID-AARCH64-NOT: libclang_rt.safestack -// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ -// RUN: -target arm-linux-androideabi -fuse-ld=ld -fsanitize=cfi \ -// RUN: --sysroot=%S/Inputs/basic_android_tree \ -// RUN: | FileCheck --check-prefix=CHECK-CFI-ANDROID %s -// -// CHECK-CFI-ANDROID: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}" -// CHECK-CFI-ANDROID-NOT: libclang_rt.cfi -// CHECK-CFI-ANDROID-NOT: __cfi_check - -// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ -// RUN: -target arm-linux-androideabi -fuse-ld=ld -fsanitize=cfi \ -// RUN: -fsanitize-cfi-cross-dso \ -// RUN: --sysroot=%S/Inputs/basic_android_tree \ -// RUN: | FileCheck --check-prefix=CHECK-CROSSDSO-CFI-ANDROID %s -// -// CHECK-CROSSDSO-CFI-ANDROID: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}" -// CHECK-CROSSDSO-CFI-ANDROID-NOT: libclang_rt.cfi -// CHECK-CROSSDSO-CFI-ANDROID: -export-dynamic-symbol=__cfi_check -// CHECK-CROSSDSO-CFI-ANDROID-NOT: libclang_rt.cfi - // RUN: %clang -fsanitize=undefined %s -### -o %t.o 2>&1 \ // RUN: -target x86_64-scei-ps4 -fuse-ld=ld \ // RUN: -shared \ Index: cfe/trunk/lib/Driver/SanitizerArgs.cpp === --- cfe/trunk/lib/Driver/SanitizerArgs.cpp +++ cfe/trunk/lib/Driver/SanitizerArgs.cpp @@ -171,19 +171,23 @@ } bool SanitizerArgs::needsUbsanRt() const { - return ((Sanitizers.Mask & NeedsUbsanRt & ~TrapSanitizers.Mask) || - CoverageFeatures) && - !Sanitizers.has(Address) && !Sanitizers.has(Memory) && - !Sanitizers.has(Thread) && !Sanitizers.has(DataFlow) && - !Sanitizers.has(Leak) && !CfiCrossDso; + // All of these include ubsan. + if (needsAsanRt() || needsMsanRt() || needsTsanRt() || needsDfsanRt() || + needsLsanRt() || needsCfiDiagRt()) +return false; + + return (Sanitizers.Mask & NeedsUbsanRt & ~TrapSanitizers.Mask) || + CoverageFeatures; } bool SanitizerArgs::needsCfiRt() const { - return !(Sanitizers.Mask & CFI & ~TrapSanitizers.Mask) && CfiCrossDso; + return !(Sanitizers.Mask & CFI & ~TrapSanitizers.Mask) && CfiCrossDso && + !ImplicitCfiRuntime; } bool SanitizerArgs::needsCfiDiagRt() const { - return (Sanitizers.Mask & CFI & ~TrapSanitizers.Mask) && CfiCrossD
[PATCH] D38430: Enable -pie and --enable-new-dtags by default on Android.
eugenis added a comment. ping https://reviews.llvm.org/D38430 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D33605: Provide an acccessor to get the Args of a ToolChain
eugenis added a comment. What's stopping anyone from removing this method as dead code? Repository: rL LLVM https://reviews.llvm.org/D33605 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D32842: Specify which sanitizers are covered by a sanitizer blacklist
eugenis added a comment. This change scares me a bit, to be honest. Is this really that big of a problem? Blacklists are not supposed to be big, maybe we can tolerate a few false negatives? Consider extending the blacklist syntax instead, the same way Valgrind does. Blacklist entries could be annotated with a list of sanitizers they apply to, like asan,ubsan : src: file.cc:line or an even less verbose way using sections [asan] src: src: [msan] src: As an extra benefit, all default blacklists can be merged into one. https://reviews.llvm.org/D32842 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D41054: Teach clang/NetBSD about additional dependencies for sanitizers
eugenis added a comment. One problem with interceptors is that any sanitized binary looks (to a configure-like script) as if it implements forkpty. But an attempt to use forkpty without actually linking -lutil will fail at runtime, because interceptors are just wrappers. Repository: rL LLVM https://reviews.llvm.org/D41054 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D41054: Teach clang/NetBSD about additional dependencies for sanitizers
eugenis added a comment. Yes, I support adding -lutil - sorry I was not clear about that. By dlerror() errors, do you mean the warnings about missing interceptors that appear with verbosity=1 (non-fatal), or something else? Repository: rL LLVM https://reviews.llvm.org/D41054 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D41417: [hwasan] Implement -fsanitize-recover=hwaddress.
eugenis created this revision. eugenis added reviewers: kcc, alekseyshl. Herald added subscribers: hiraditya, kubamracek. Very similar to AddressSanitizer, with the exception of the error type encoding. https://reviews.llvm.org/D41417 Files: clang/lib/CodeGen/BackendUtil.cpp compiler-rt/lib/hwasan/hwasan.cc compiler-rt/lib/hwasan/hwasan_interface_internal.h compiler-rt/lib/hwasan/hwasan_linux.cc compiler-rt/test/hwasan/TestCases/halt-on-error.cc llvm/include/llvm/Transforms/Instrumentation.h llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp llvm/test/Instrumentation/HWAddressSanitizer/basic.ll llvm/test/Instrumentation/HWAddressSanitizer/with-calls.ll Index: llvm/test/Instrumentation/HWAddressSanitizer/with-calls.ll === --- llvm/test/Instrumentation/HWAddressSanitizer/with-calls.ll +++ llvm/test/Instrumentation/HWAddressSanitizer/with-calls.ll @@ -1,14 +1,16 @@ ; Test basic address sanitizer instrumentation. ; -; RUN: opt < %s -hwasan -hwasan-instrument-with-calls -S | FileCheck %s +; RUN: opt < %s -hwasan -hwasan-instrument-with-calls -S | FileCheck %s --check-prefixes=CHECK,ABORT +; RUN: opt < %s -hwasan -hwasan-instrument-with-calls -hwasan-recover=1 -S | FileCheck %s --check-prefixes=CHECK,RECOVER target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" target triple = "aarch64--linux-android" define i8 @test_load8(i8* %a) sanitize_hwaddress { ; CHECK-LABEL: @test_load8( ; CHECK: %[[A:[^ ]*]] = ptrtoint i8* %a to i64 -; CHECK: call void @__hwasan_load1(i64 %[[A]]) +; ABORT: call void @__hwasan_load1(i64 %[[A]]) +; RECOVER: call void @__hwasan_load1_noabort(i64 %[[A]]) ; CHECK: %[[B:[^ ]*]] = load i8, i8* %a ; CHECK: ret i8 %[[B]] @@ -20,7 +22,8 @@ define i16 @test_load16(i16* %a) sanitize_hwaddress { ; CHECK-LABEL: @test_load16( ; CHECK: %[[A:[^ ]*]] = ptrtoint i16* %a to i64 -; CHECK: call void @__hwasan_load2(i64 %[[A]]) +; ABORT: call void @__hwasan_load2(i64 %[[A]]) +; RECOVER: call void @__hwasan_load2_noabort(i64 %[[A]]) ; CHECK: %[[B:[^ ]*]] = load i16, i16* %a ; CHECK: ret i16 %[[B]] @@ -32,7 +35,8 @@ define i32 @test_load32(i32* %a) sanitize_hwaddress { ; CHECK-LABEL: @test_load32( ; CHECK: %[[A:[^ ]*]] = ptrtoint i32* %a to i64 -; CHECK: call void @__hwasan_load4(i64 %[[A]]) +; ABORT: call void @__hwasan_load4(i64 %[[A]]) +; RECOVER: call void @__hwasan_load4_noabort(i64 %[[A]]) ; CHECK: %[[B:[^ ]*]] = load i32, i32* %a ; CHECK: ret i32 %[[B]] @@ -44,7 +48,8 @@ define i64 @test_load64(i64* %a) sanitize_hwaddress { ; CHECK-LABEL: @test_load64( ; CHECK: %[[A:[^ ]*]] = ptrtoint i64* %a to i64 -; CHECK: call void @__hwasan_load8(i64 %[[A]]) +; ABORT: call void @__hwasan_load8(i64 %[[A]]) +; RECOVER: call void @__hwasan_load8_noabort(i64 %[[A]]) ; CHECK: %[[B:[^ ]*]] = load i64, i64* %a ; CHECK: ret i64 %[[B]] @@ -56,7 +61,8 @@ define i128 @test_load128(i128* %a) sanitize_hwaddress { ; CHECK-LABEL: @test_load128( ; CHECK: %[[A:[^ ]*]] = ptrtoint i128* %a to i64 -; CHECK: call void @__hwasan_load16(i64 %[[A]]) +; ABORT: call void @__hwasan_load16(i64 %[[A]]) +; RECOVER: call void @__hwasan_load16_noabort(i64 %[[A]]) ; CHECK: %[[B:[^ ]*]] = load i128, i128* %a ; CHECK: ret i128 %[[B]] @@ -68,7 +74,8 @@ define i40 @test_load40(i40* %a) sanitize_hwaddress { ; CHECK-LABEL: @test_load40( ; CHECK: %[[A:[^ ]*]] = ptrtoint i40* %a to i64 -; CHECK: call void @__hwasan_load(i64 %[[A]], i64 5) +; ABORT: call void @__hwasan_load(i64 %[[A]], i64 5) +; RECOVER: call void @__hwasan_load_noabort(i64 %[[A]], i64 5) ; CHECK: %[[B:[^ ]*]] = load i40, i40* %a ; CHECK: ret i40 %[[B]] @@ -80,7 +87,8 @@ define void @test_store8(i8* %a, i8 %b) sanitize_hwaddress { ; CHECK-LABEL: @test_store8( ; CHECK: %[[A:[^ ]*]] = ptrtoint i8* %a to i64 -; CHECK: call void @__hwasan_store1(i64 %[[A]]) +; ABORT: call void @__hwasan_store1(i64 %[[A]]) +; RECOVER: call void @__hwasan_store1_noabort(i64 %[[A]]) ; CHECK: store i8 %b, i8* %a ; CHECK: ret void @@ -92,7 +100,8 @@ define void @test_store16(i16* %a, i16 %b) sanitize_hwaddress { ; CHECK-LABEL: @test_store16( ; CHECK: %[[A:[^ ]*]] = ptrtoint i16* %a to i64 -; CHECK: call void @__hwasan_store2(i64 %[[A]]) +; ABORT: call void @__hwasan_store2(i64 %[[A]]) +; RECOVER: call void @__hwasan_store2_noabort(i64 %[[A]]) ; CHECK: store i16 %b, i16* %a ; CHECK: ret void @@ -104,7 +113,8 @@ define void @test_store32(i32* %a, i32 %b) sanitize_hwaddress { ; CHECK-LABEL: @test_store32( ; CHECK: %[[A:[^ ]*]] = ptrtoint i32* %a to i64 -; CHECK: call void @__hwasan_store4(i64 %[[A]]) +; ABORT: call void @__hwasan_store4(i64 %[[A]]) +; RECOVER: call void @__hwasan_store4_noabort(i64 %[[A]]) ; CHECK: store i32 %b, i32* %a ; CHECK: ret void @@ -116,7 +126,8 @@ define void @test_store64(i64* %a, i64 %b) sanitize_hwaddress { ; CHECK-LABEL: @test_store64( ; CHECK: %[[A:[^ ]*]] = ptrtoint i64* %a to i64 -; CHECK: call void
[PATCH] D41417: [hwasan] Implement -fsanitize-recover=hwaddress.
eugenis added inline comments. Comment at: compiler-rt/lib/hwasan/hwasan.cc:255 -template +template __attribute__((always_inline, nodebug)) kcc wrote: > I'd prefer enums to booleans, for better readability good idea! https://reviews.llvm.org/D41417 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D41417: [hwasan] Implement -fsanitize-recover=hwaddress.
eugenis updated this revision to Diff 127640. eugenis added a comment. Replaced booleans with enums. Added __builtin_unreachable in non-recover variants of callbacks. https://reviews.llvm.org/D41417 Files: clang/lib/CodeGen/BackendUtil.cpp compiler-rt/lib/hwasan/hwasan.cc compiler-rt/lib/hwasan/hwasan_interface_internal.h compiler-rt/lib/hwasan/hwasan_linux.cc compiler-rt/test/hwasan/TestCases/halt-on-error.cc llvm/include/llvm/Transforms/Instrumentation.h llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp llvm/test/Instrumentation/HWAddressSanitizer/basic.ll llvm/test/Instrumentation/HWAddressSanitizer/with-calls.ll Index: llvm/test/Instrumentation/HWAddressSanitizer/with-calls.ll === --- llvm/test/Instrumentation/HWAddressSanitizer/with-calls.ll +++ llvm/test/Instrumentation/HWAddressSanitizer/with-calls.ll @@ -1,14 +1,16 @@ ; Test basic address sanitizer instrumentation. ; -; RUN: opt < %s -hwasan -hwasan-instrument-with-calls -S | FileCheck %s +; RUN: opt < %s -hwasan -hwasan-instrument-with-calls -S | FileCheck %s --check-prefixes=CHECK,ABORT +; RUN: opt < %s -hwasan -hwasan-instrument-with-calls -hwasan-recover=1 -S | FileCheck %s --check-prefixes=CHECK,RECOVER target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" target triple = "aarch64--linux-android" define i8 @test_load8(i8* %a) sanitize_hwaddress { ; CHECK-LABEL: @test_load8( ; CHECK: %[[A:[^ ]*]] = ptrtoint i8* %a to i64 -; CHECK: call void @__hwasan_load1(i64 %[[A]]) +; ABORT: call void @__hwasan_load1(i64 %[[A]]) +; RECOVER: call void @__hwasan_load1_noabort(i64 %[[A]]) ; CHECK: %[[B:[^ ]*]] = load i8, i8* %a ; CHECK: ret i8 %[[B]] @@ -20,7 +22,8 @@ define i16 @test_load16(i16* %a) sanitize_hwaddress { ; CHECK-LABEL: @test_load16( ; CHECK: %[[A:[^ ]*]] = ptrtoint i16* %a to i64 -; CHECK: call void @__hwasan_load2(i64 %[[A]]) +; ABORT: call void @__hwasan_load2(i64 %[[A]]) +; RECOVER: call void @__hwasan_load2_noabort(i64 %[[A]]) ; CHECK: %[[B:[^ ]*]] = load i16, i16* %a ; CHECK: ret i16 %[[B]] @@ -32,7 +35,8 @@ define i32 @test_load32(i32* %a) sanitize_hwaddress { ; CHECK-LABEL: @test_load32( ; CHECK: %[[A:[^ ]*]] = ptrtoint i32* %a to i64 -; CHECK: call void @__hwasan_load4(i64 %[[A]]) +; ABORT: call void @__hwasan_load4(i64 %[[A]]) +; RECOVER: call void @__hwasan_load4_noabort(i64 %[[A]]) ; CHECK: %[[B:[^ ]*]] = load i32, i32* %a ; CHECK: ret i32 %[[B]] @@ -44,7 +48,8 @@ define i64 @test_load64(i64* %a) sanitize_hwaddress { ; CHECK-LABEL: @test_load64( ; CHECK: %[[A:[^ ]*]] = ptrtoint i64* %a to i64 -; CHECK: call void @__hwasan_load8(i64 %[[A]]) +; ABORT: call void @__hwasan_load8(i64 %[[A]]) +; RECOVER: call void @__hwasan_load8_noabort(i64 %[[A]]) ; CHECK: %[[B:[^ ]*]] = load i64, i64* %a ; CHECK: ret i64 %[[B]] @@ -56,7 +61,8 @@ define i128 @test_load128(i128* %a) sanitize_hwaddress { ; CHECK-LABEL: @test_load128( ; CHECK: %[[A:[^ ]*]] = ptrtoint i128* %a to i64 -; CHECK: call void @__hwasan_load16(i64 %[[A]]) +; ABORT: call void @__hwasan_load16(i64 %[[A]]) +; RECOVER: call void @__hwasan_load16_noabort(i64 %[[A]]) ; CHECK: %[[B:[^ ]*]] = load i128, i128* %a ; CHECK: ret i128 %[[B]] @@ -68,7 +74,8 @@ define i40 @test_load40(i40* %a) sanitize_hwaddress { ; CHECK-LABEL: @test_load40( ; CHECK: %[[A:[^ ]*]] = ptrtoint i40* %a to i64 -; CHECK: call void @__hwasan_load(i64 %[[A]], i64 5) +; ABORT: call void @__hwasan_load(i64 %[[A]], i64 5) +; RECOVER: call void @__hwasan_load_noabort(i64 %[[A]], i64 5) ; CHECK: %[[B:[^ ]*]] = load i40, i40* %a ; CHECK: ret i40 %[[B]] @@ -80,7 +87,8 @@ define void @test_store8(i8* %a, i8 %b) sanitize_hwaddress { ; CHECK-LABEL: @test_store8( ; CHECK: %[[A:[^ ]*]] = ptrtoint i8* %a to i64 -; CHECK: call void @__hwasan_store1(i64 %[[A]]) +; ABORT: call void @__hwasan_store1(i64 %[[A]]) +; RECOVER: call void @__hwasan_store1_noabort(i64 %[[A]]) ; CHECK: store i8 %b, i8* %a ; CHECK: ret void @@ -92,7 +100,8 @@ define void @test_store16(i16* %a, i16 %b) sanitize_hwaddress { ; CHECK-LABEL: @test_store16( ; CHECK: %[[A:[^ ]*]] = ptrtoint i16* %a to i64 -; CHECK: call void @__hwasan_store2(i64 %[[A]]) +; ABORT: call void @__hwasan_store2(i64 %[[A]]) +; RECOVER: call void @__hwasan_store2_noabort(i64 %[[A]]) ; CHECK: store i16 %b, i16* %a ; CHECK: ret void @@ -104,7 +113,8 @@ define void @test_store32(i32* %a, i32 %b) sanitize_hwaddress { ; CHECK-LABEL: @test_store32( ; CHECK: %[[A:[^ ]*]] = ptrtoint i32* %a to i64 -; CHECK: call void @__hwasan_store4(i64 %[[A]]) +; ABORT: call void @__hwasan_store4(i64 %[[A]]) +; RECOVER: call void @__hwasan_store4_noabort(i64 %[[A]]) ; CHECK: store i32 %b, i32* %a ; CHECK: ret void @@ -116,7 +126,8 @@ define void @test_store64(i64* %a, i64 %b) sanitize_hwaddress { ; CHECK-LABEL: @test_store64( ; CHECK: %[[A:[^ ]*]] = ptrtoint i64* %a to i64 -; CHECK: call void @__hwasan_store8(i64 %[[A]]) +; ABOR
[PATCH] D41417: [hwasan] Implement -fsanitize-recover=hwaddress.
eugenis updated this revision to Diff 127642. eugenis added a comment. Tweaked a test. https://reviews.llvm.org/D41417 Files: clang/lib/CodeGen/BackendUtil.cpp compiler-rt/lib/hwasan/hwasan.cc compiler-rt/lib/hwasan/hwasan_interface_internal.h compiler-rt/lib/hwasan/hwasan_linux.cc compiler-rt/test/hwasan/TestCases/halt-on-error.cc llvm/include/llvm/Transforms/Instrumentation.h llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp llvm/test/Instrumentation/HWAddressSanitizer/basic.ll llvm/test/Instrumentation/HWAddressSanitizer/with-calls.ll Index: llvm/test/Instrumentation/HWAddressSanitizer/with-calls.ll === --- llvm/test/Instrumentation/HWAddressSanitizer/with-calls.ll +++ llvm/test/Instrumentation/HWAddressSanitizer/with-calls.ll @@ -1,14 +1,16 @@ ; Test basic address sanitizer instrumentation. ; -; RUN: opt < %s -hwasan -hwasan-instrument-with-calls -S | FileCheck %s +; RUN: opt < %s -hwasan -hwasan-instrument-with-calls -S | FileCheck %s --check-prefixes=CHECK,ABORT +; RUN: opt < %s -hwasan -hwasan-instrument-with-calls -hwasan-recover=1 -S | FileCheck %s --check-prefixes=CHECK,RECOVER target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" target triple = "aarch64--linux-android" define i8 @test_load8(i8* %a) sanitize_hwaddress { ; CHECK-LABEL: @test_load8( ; CHECK: %[[A:[^ ]*]] = ptrtoint i8* %a to i64 -; CHECK: call void @__hwasan_load1(i64 %[[A]]) +; ABORT: call void @__hwasan_load1(i64 %[[A]]) +; RECOVER: call void @__hwasan_load1_noabort(i64 %[[A]]) ; CHECK: %[[B:[^ ]*]] = load i8, i8* %a ; CHECK: ret i8 %[[B]] @@ -20,7 +22,8 @@ define i16 @test_load16(i16* %a) sanitize_hwaddress { ; CHECK-LABEL: @test_load16( ; CHECK: %[[A:[^ ]*]] = ptrtoint i16* %a to i64 -; CHECK: call void @__hwasan_load2(i64 %[[A]]) +; ABORT: call void @__hwasan_load2(i64 %[[A]]) +; RECOVER: call void @__hwasan_load2_noabort(i64 %[[A]]) ; CHECK: %[[B:[^ ]*]] = load i16, i16* %a ; CHECK: ret i16 %[[B]] @@ -32,7 +35,8 @@ define i32 @test_load32(i32* %a) sanitize_hwaddress { ; CHECK-LABEL: @test_load32( ; CHECK: %[[A:[^ ]*]] = ptrtoint i32* %a to i64 -; CHECK: call void @__hwasan_load4(i64 %[[A]]) +; ABORT: call void @__hwasan_load4(i64 %[[A]]) +; RECOVER: call void @__hwasan_load4_noabort(i64 %[[A]]) ; CHECK: %[[B:[^ ]*]] = load i32, i32* %a ; CHECK: ret i32 %[[B]] @@ -44,7 +48,8 @@ define i64 @test_load64(i64* %a) sanitize_hwaddress { ; CHECK-LABEL: @test_load64( ; CHECK: %[[A:[^ ]*]] = ptrtoint i64* %a to i64 -; CHECK: call void @__hwasan_load8(i64 %[[A]]) +; ABORT: call void @__hwasan_load8(i64 %[[A]]) +; RECOVER: call void @__hwasan_load8_noabort(i64 %[[A]]) ; CHECK: %[[B:[^ ]*]] = load i64, i64* %a ; CHECK: ret i64 %[[B]] @@ -56,7 +61,8 @@ define i128 @test_load128(i128* %a) sanitize_hwaddress { ; CHECK-LABEL: @test_load128( ; CHECK: %[[A:[^ ]*]] = ptrtoint i128* %a to i64 -; CHECK: call void @__hwasan_load16(i64 %[[A]]) +; ABORT: call void @__hwasan_load16(i64 %[[A]]) +; RECOVER: call void @__hwasan_load16_noabort(i64 %[[A]]) ; CHECK: %[[B:[^ ]*]] = load i128, i128* %a ; CHECK: ret i128 %[[B]] @@ -68,7 +74,8 @@ define i40 @test_load40(i40* %a) sanitize_hwaddress { ; CHECK-LABEL: @test_load40( ; CHECK: %[[A:[^ ]*]] = ptrtoint i40* %a to i64 -; CHECK: call void @__hwasan_load(i64 %[[A]], i64 5) +; ABORT: call void @__hwasan_load(i64 %[[A]], i64 5) +; RECOVER: call void @__hwasan_load_noabort(i64 %[[A]], i64 5) ; CHECK: %[[B:[^ ]*]] = load i40, i40* %a ; CHECK: ret i40 %[[B]] @@ -80,7 +87,8 @@ define void @test_store8(i8* %a, i8 %b) sanitize_hwaddress { ; CHECK-LABEL: @test_store8( ; CHECK: %[[A:[^ ]*]] = ptrtoint i8* %a to i64 -; CHECK: call void @__hwasan_store1(i64 %[[A]]) +; ABORT: call void @__hwasan_store1(i64 %[[A]]) +; RECOVER: call void @__hwasan_store1_noabort(i64 %[[A]]) ; CHECK: store i8 %b, i8* %a ; CHECK: ret void @@ -92,7 +100,8 @@ define void @test_store16(i16* %a, i16 %b) sanitize_hwaddress { ; CHECK-LABEL: @test_store16( ; CHECK: %[[A:[^ ]*]] = ptrtoint i16* %a to i64 -; CHECK: call void @__hwasan_store2(i64 %[[A]]) +; ABORT: call void @__hwasan_store2(i64 %[[A]]) +; RECOVER: call void @__hwasan_store2_noabort(i64 %[[A]]) ; CHECK: store i16 %b, i16* %a ; CHECK: ret void @@ -104,7 +113,8 @@ define void @test_store32(i32* %a, i32 %b) sanitize_hwaddress { ; CHECK-LABEL: @test_store32( ; CHECK: %[[A:[^ ]*]] = ptrtoint i32* %a to i64 -; CHECK: call void @__hwasan_store4(i64 %[[A]]) +; ABORT: call void @__hwasan_store4(i64 %[[A]]) +; RECOVER: call void @__hwasan_store4_noabort(i64 %[[A]]) ; CHECK: store i32 %b, i32* %a ; CHECK: ret void @@ -116,7 +126,8 @@ define void @test_store64(i64* %a, i64 %b) sanitize_hwaddress { ; CHECK-LABEL: @test_store64( ; CHECK: %[[A:[^ ]*]] = ptrtoint i64* %a to i64 -; CHECK: call void @__hwasan_store8(i64 %[[A]]) +; ABORT: call void @__hwasan_store8(i64 %[[A]]) +; RECOVER: call void @__hwasan_store8
[PATCH] D41417: [hwasan] Implement -fsanitize-recover=hwaddress.
This revision was automatically updated to reflect the committed changes. Closed by commit rC321203: [hwasan] Implement -fsanitize-recover=hwaddress. (authored by eugenis, committed by ). Changed prior to commit: https://reviews.llvm.org/D41417?vs=127642&id=127760#toc Repository: rC Clang https://reviews.llvm.org/D41417 Files: lib/CodeGen/BackendUtil.cpp Index: lib/CodeGen/BackendUtil.cpp === --- lib/CodeGen/BackendUtil.cpp +++ lib/CodeGen/BackendUtil.cpp @@ -239,7 +239,11 @@ static void addHWAddressSanitizerPasses(const PassManagerBuilder &Builder, legacy::PassManagerBase &PM) { - PM.add(createHWAddressSanitizerPass()); + const PassManagerBuilderWrapper &BuilderWrapper = + static_cast(Builder); + const CodeGenOptions &CGOpts = BuilderWrapper.getCGOpts(); + bool Recover = CGOpts.SanitizeRecover.has(SanitizerKind::HWAddress); + PM.add(createHWAddressSanitizerPass(Recover)); } static void addMemorySanitizerPass(const PassManagerBuilder &Builder, Index: lib/CodeGen/BackendUtil.cpp === --- lib/CodeGen/BackendUtil.cpp +++ lib/CodeGen/BackendUtil.cpp @@ -239,7 +239,11 @@ static void addHWAddressSanitizerPasses(const PassManagerBuilder &Builder, legacy::PassManagerBase &PM) { - PM.add(createHWAddressSanitizerPass()); + const PassManagerBuilderWrapper &BuilderWrapper = + static_cast(Builder); + const CodeGenOptions &CGOpts = BuilderWrapper.getCGOpts(); + bool Recover = CGOpts.SanitizeRecover.has(SanitizerKind::HWAddress); + PM.add(createHWAddressSanitizerPass(Recover)); } static void addMemorySanitizerPass(const PassManagerBuilder &Builder, ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D44229: Don't use -pie in relocatable link.
eugenis created this revision. eugenis added a reviewer: srhines. Android, in particular, got PIE enabled by default in r316606. It resulted in relocatable links passing both -r and -pie to the linker, which is not allowed. https://reviews.llvm.org/D44229 Files: clang/lib/Driver/ToolChains/Gnu.cpp clang/test/Driver/android-pie.c Index: clang/test/Driver/android-pie.c === --- clang/test/Driver/android-pie.c +++ clang/test/Driver/android-pie.c @@ -64,3 +64,20 @@ // RUN: | FileCheck --check-prefix=NO-PIE %s // RUN: %clang %s -### -o %t.o 2>&1 -pie -no-pie --target=arm-linux-androideabi24 \ // RUN: | FileCheck --check-prefix=NO-PIE %s + +// Static/shared/relocatable disable -pie + +// RUN: %clang %s -### --target=aarch64-linux-android -static 2>&1 \ +// RUN: | FileCheck %s -check-prefix=CHECK-STATIC +// CHECK-STATIC-NOT: "-pie" +// CHECK-STATIC: -static + +// RUN: %clang %s -### --target=aarch64-linux-android -shared 2>&1 \ +// RUN: | FileCheck %s -check-prefix=CHECK-SHARED +// CHECK-SHARED-NOT: "-pie" +// CHECK-SHARED: "-shared" + +// RUN: %clang %s -### --target=aarch64-linux-android -r 2>&1 \ +// RUN: | FileCheck %s -check-prefix=CHECK-RELOCATABLE +// CHECK-RELOCATABLE-NOT: "-pie" +// CHECK-RELOCATABLE: "-r" Index: clang/lib/Driver/ToolChains/Gnu.cpp === --- clang/lib/Driver/ToolChains/Gnu.cpp +++ clang/lib/Driver/ToolChains/Gnu.cpp @@ -307,7 +307,8 @@ } static bool getPIE(const ArgList &Args, const toolchains::Linux &ToolChain) { - if (Args.hasArg(options::OPT_shared) || Args.hasArg(options::OPT_static)) + if (Args.hasArg(options::OPT_shared) || Args.hasArg(options::OPT_static) || + Args.hasArg(options::OPT_r)) return false; Arg *A = Args.getLastArg(options::OPT_pie, options::OPT_no_pie, Index: clang/test/Driver/android-pie.c === --- clang/test/Driver/android-pie.c +++ clang/test/Driver/android-pie.c @@ -64,3 +64,20 @@ // RUN: | FileCheck --check-prefix=NO-PIE %s // RUN: %clang %s -### -o %t.o 2>&1 -pie -no-pie --target=arm-linux-androideabi24 \ // RUN: | FileCheck --check-prefix=NO-PIE %s + +// Static/shared/relocatable disable -pie + +// RUN: %clang %s -### --target=aarch64-linux-android -static 2>&1 \ +// RUN: | FileCheck %s -check-prefix=CHECK-STATIC +// CHECK-STATIC-NOT: "-pie" +// CHECK-STATIC: -static + +// RUN: %clang %s -### --target=aarch64-linux-android -shared 2>&1 \ +// RUN: | FileCheck %s -check-prefix=CHECK-SHARED +// CHECK-SHARED-NOT: "-pie" +// CHECK-SHARED: "-shared" + +// RUN: %clang %s -### --target=aarch64-linux-android -r 2>&1 \ +// RUN: | FileCheck %s -check-prefix=CHECK-RELOCATABLE +// CHECK-RELOCATABLE-NOT: "-pie" +// CHECK-RELOCATABLE: "-r" Index: clang/lib/Driver/ToolChains/Gnu.cpp === --- clang/lib/Driver/ToolChains/Gnu.cpp +++ clang/lib/Driver/ToolChains/Gnu.cpp @@ -307,7 +307,8 @@ } static bool getPIE(const ArgList &Args, const toolchains::Linux &ToolChain) { - if (Args.hasArg(options::OPT_shared) || Args.hasArg(options::OPT_static)) + if (Args.hasArg(options::OPT_shared) || Args.hasArg(options::OPT_static) || + Args.hasArg(options::OPT_r)) return false; Arg *A = Args.getLastArg(options::OPT_pie, options::OPT_no_pie, ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D44229: Don't use -pie in relocatable link.
eugenis added inline comments. Comment at: clang/lib/Driver/ToolChains/Gnu.cpp:311 + if (Args.hasArg(options::OPT_shared) || Args.hasArg(options::OPT_static) || + Args.hasArg(options::OPT_r)) return false; mgrang wrote: > We also need to check for -Wl,-r and -Xlinker -r options. I don't think it is driver's job to parse -Wl or -Xlinker arguments. There is always -no-pie. https://reviews.llvm.org/D44229 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D44229: Don't use -pie in relocatable link.
This revision was automatically updated to reflect the committed changes. Closed by commit rC327165: Don't use -pie in relocatable link. (authored by eugenis, committed by ). Changed prior to commit: https://reviews.llvm.org/D44229?vs=137493&id=137809#toc Repository: rC Clang https://reviews.llvm.org/D44229 Files: lib/Driver/ToolChains/Gnu.cpp test/Driver/android-pie.c Index: test/Driver/android-pie.c === --- test/Driver/android-pie.c +++ test/Driver/android-pie.c @@ -64,3 +64,20 @@ // RUN: | FileCheck --check-prefix=NO-PIE %s // RUN: %clang %s -### -o %t.o 2>&1 -pie -no-pie --target=arm-linux-androideabi24 \ // RUN: | FileCheck --check-prefix=NO-PIE %s + +// Static/shared/relocatable disable -pie + +// RUN: %clang %s -### --target=aarch64-linux-android -static 2>&1 \ +// RUN: | FileCheck %s -check-prefix=CHECK-STATIC +// CHECK-STATIC-NOT: "-pie" +// CHECK-STATIC: -static + +// RUN: %clang %s -### --target=aarch64-linux-android -shared 2>&1 \ +// RUN: | FileCheck %s -check-prefix=CHECK-SHARED +// CHECK-SHARED-NOT: "-pie" +// CHECK-SHARED: "-shared" + +// RUN: %clang %s -### --target=aarch64-linux-android -r 2>&1 \ +// RUN: | FileCheck %s -check-prefix=CHECK-RELOCATABLE +// CHECK-RELOCATABLE-NOT: "-pie" +// CHECK-RELOCATABLE: "-r" Index: lib/Driver/ToolChains/Gnu.cpp === --- lib/Driver/ToolChains/Gnu.cpp +++ lib/Driver/ToolChains/Gnu.cpp @@ -307,7 +307,8 @@ } static bool getPIE(const ArgList &Args, const toolchains::Linux &ToolChain) { - if (Args.hasArg(options::OPT_shared) || Args.hasArg(options::OPT_static)) + if (Args.hasArg(options::OPT_shared) || Args.hasArg(options::OPT_static) || + Args.hasArg(options::OPT_r)) return false; Arg *A = Args.getLastArg(options::OPT_pie, options::OPT_no_pie, Index: test/Driver/android-pie.c === --- test/Driver/android-pie.c +++ test/Driver/android-pie.c @@ -64,3 +64,20 @@ // RUN: | FileCheck --check-prefix=NO-PIE %s // RUN: %clang %s -### -o %t.o 2>&1 -pie -no-pie --target=arm-linux-androideabi24 \ // RUN: | FileCheck --check-prefix=NO-PIE %s + +// Static/shared/relocatable disable -pie + +// RUN: %clang %s -### --target=aarch64-linux-android -static 2>&1 \ +// RUN: | FileCheck %s -check-prefix=CHECK-STATIC +// CHECK-STATIC-NOT: "-pie" +// CHECK-STATIC: -static + +// RUN: %clang %s -### --target=aarch64-linux-android -shared 2>&1 \ +// RUN: | FileCheck %s -check-prefix=CHECK-SHARED +// CHECK-SHARED-NOT: "-pie" +// CHECK-SHARED: "-shared" + +// RUN: %clang %s -### --target=aarch64-linux-android -r 2>&1 \ +// RUN: | FileCheck %s -check-prefix=CHECK-RELOCATABLE +// CHECK-RELOCATABLE-NOT: "-pie" +// CHECK-RELOCATABLE: "-r" Index: lib/Driver/ToolChains/Gnu.cpp === --- lib/Driver/ToolChains/Gnu.cpp +++ lib/Driver/ToolChains/Gnu.cpp @@ -307,7 +307,8 @@ } static bool getPIE(const ArgList &Args, const toolchains::Linux &ToolChain) { - if (Args.hasArg(options::OPT_shared) || Args.hasArg(options::OPT_static)) + if (Args.hasArg(options::OPT_shared) || Args.hasArg(options::OPT_static) || + Args.hasArg(options::OPT_r)) return false; Arg *A = Args.getLastArg(options::OPT_pie, options::OPT_no_pie, ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D44645: [test] Fix Cross-DSO CFI Android sanitizer test for -rtlib=compiler-rt
eugenis added inline comments. Comment at: test/Driver/sanitizer-ld.c:517 // CHECK-CFI-CROSS-DSO-ANDROID: "{{.*}}ld{{(.exe)?}}" // CHECK-CFI-CROSS-DSO-ANDROID-NOT: libclang_rt. mgorny wrote: > (an alternative would be to replace this 'NOT' clause with more specific > library name — but I don't know which library could 'accidentally' appear > here) Yes, it would be better to check for -NOT: libclang_rt.cfi Repository: rC Clang https://reviews.llvm.org/D44645 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D44655: [Sanitizer] Allow builtins for Cross-DSO CFI on Android
eugenis accepted this revision. eugenis added a comment. This revision is now accepted and ready to land. See my comment in https://reviews.llvm.org/D44655, but this change is also fine with me. Repository: rC Clang https://reviews.llvm.org/D44655 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D44655: [Sanitizer] Allow builtins for Cross-DSO CFI on Android
eugenis added a comment. Indeed! https://reviews.llvm.org/D44645 Repository: rC Clang https://reviews.llvm.org/D44655 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D44655: [Sanitizer] Allow builtins for Cross-DSO CFI on Android
eugenis added a comment. Since the test is about cfi, not builtins, I think it's better to check for the cfi library explicitly. Repository: rC Clang https://reviews.llvm.org/D44655 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D44655: [Sanitizer] Allow builtins for Cross-DSO CFI on Android
eugenis accepted this revision. eugenis added a comment. LGTM https://reviews.llvm.org/D44655 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48373: [Driver] Make scudo compatible with -fsanitize-minimal-runtime
eugenis requested changes to this revision. eugenis added a comment. This revision now requires changes to proceed. Please add a test. Repository: rC Clang https://reviews.llvm.org/D48373 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48390: ASan docs: no_sanitize("address") works on globals.
eugenis created this revision. eugenis added a reviewer: alekseyshl. Mention that no_sanitize attribute can be used with globals. https://reviews.llvm.org/D48390 Files: clang/docs/AddressSanitizer.rst Index: clang/docs/AddressSanitizer.rst === --- clang/docs/AddressSanitizer.rst +++ clang/docs/AddressSanitizer.rst @@ -197,13 +197,17 @@ Disabling Instrumentation with ``__attribute__((no_sanitize("address")))`` -- -Some code should not be instrumented by AddressSanitizer. One may use the -function attribute ``__attribute__((no_sanitize("address")))`` (which has -deprecated synonyms `no_sanitize_address` and `no_address_safety_analysis`) to -disable instrumentation of a particular function. This attribute may not be -supported by other compilers, so we suggest to use it together with +Some code should not be instrumented by AddressSanitizer. One may use +the attribute ``__attribute__((no_sanitize("address")))`` (which has +deprecated synonyms `no_sanitize_address` and +`no_address_safety_analysis`) to disable instrumentation of a +particular function. This attribute may not be supported by other +compilers, so we suggest to use it together with ``__has_feature(address_sanitizer)``. +The same attribute used on a global variable prevents AddressSanitizer +from adding redzones around it and detecting out of bounds accesses. + Suppressing Errors in Recompiled Code (Blacklist) - Index: clang/docs/AddressSanitizer.rst === --- clang/docs/AddressSanitizer.rst +++ clang/docs/AddressSanitizer.rst @@ -197,13 +197,17 @@ Disabling Instrumentation with ``__attribute__((no_sanitize("address")))`` -- -Some code should not be instrumented by AddressSanitizer. One may use the -function attribute ``__attribute__((no_sanitize("address")))`` (which has -deprecated synonyms `no_sanitize_address` and `no_address_safety_analysis`) to -disable instrumentation of a particular function. This attribute may not be -supported by other compilers, so we suggest to use it together with +Some code should not be instrumented by AddressSanitizer. One may use +the attribute ``__attribute__((no_sanitize("address")))`` (which has +deprecated synonyms `no_sanitize_address` and +`no_address_safety_analysis`) to disable instrumentation of a +particular function. This attribute may not be supported by other +compilers, so we suggest to use it together with ``__has_feature(address_sanitizer)``. +The same attribute used on a global variable prevents AddressSanitizer +from adding redzones around it and detecting out of bounds accesses. + Suppressing Errors in Recompiled Code (Blacklist) - ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48390: ASan docs: no_sanitize("address") works on globals.
eugenis updated this revision to Diff 152140. eugenis added a comment. update AttrDocs.td https://reviews.llvm.org/D48390 Files: clang/docs/AddressSanitizer.rst clang/include/clang/Basic/AttrDocs.td Index: clang/include/clang/Basic/AttrDocs.td === --- clang/include/clang/Basic/AttrDocs.td +++ clang/include/clang/Basic/AttrDocs.td @@ -1804,13 +1804,14 @@ def NoSanitizeDocs : Documentation { let Category = DocCatFunction; let Content = [{ -Use the ``no_sanitize`` attribute on a function declaration to specify -that a particular instrumentation or set of instrumentations should not be -applied to that function. The attribute takes a list of string literals, -which have the same meaning as values accepted by the ``-fno-sanitize=`` -flag. For example, ``__attribute__((no_sanitize("address", "thread")))`` -specifies that AddressSanitizer and ThreadSanitizer should not be applied -to the function. +Use the ``no_sanitize`` attribute on a function or a global variable +declaration to specify that a particular instrumentation or set of +instrumentations should not be applied. The attribute takes a list of +string literals, which have the same meaning as values accepted by the +``-fno-sanitize=`` flag. For example, +``__attribute__((no_sanitize("address", "thread")))`` specifies that +AddressSanitizer and ThreadSanitizer should not be applied to the +function or variable. See :ref:`Controlling Code Generation ` for a full list of supported sanitizer flags. @@ -1825,9 +1826,9 @@ let Content = [{ .. _langext-address_sanitizer: -Use ``__attribute__((no_sanitize_address))`` on a function declaration to -specify that address safety instrumentation (e.g. AddressSanitizer) should -not be applied to that function. +Use ``__attribute__((no_sanitize_address))`` on a function or a global +variable declaration to specify that address safety instrumentation +(e.g. AddressSanitizer) should not be applied. }]; } Index: clang/docs/AddressSanitizer.rst === --- clang/docs/AddressSanitizer.rst +++ clang/docs/AddressSanitizer.rst @@ -197,13 +197,17 @@ Disabling Instrumentation with ``__attribute__((no_sanitize("address")))`` -- -Some code should not be instrumented by AddressSanitizer. One may use the -function attribute ``__attribute__((no_sanitize("address")))`` (which has -deprecated synonyms `no_sanitize_address` and `no_address_safety_analysis`) to -disable instrumentation of a particular function. This attribute may not be -supported by other compilers, so we suggest to use it together with +Some code should not be instrumented by AddressSanitizer. One may use +the attribute ``__attribute__((no_sanitize("address")))`` (which has +deprecated synonyms `no_sanitize_address` and +`no_address_safety_analysis`) to disable instrumentation of a +particular function. This attribute may not be supported by other +compilers, so we suggest to use it together with ``__has_feature(address_sanitizer)``. +The same attribute used on a global variable prevents AddressSanitizer +from adding redzones around it and detecting out of bounds accesses. + Suppressing Errors in Recompiled Code (Blacklist) - Index: clang/include/clang/Basic/AttrDocs.td === --- clang/include/clang/Basic/AttrDocs.td +++ clang/include/clang/Basic/AttrDocs.td @@ -1804,13 +1804,14 @@ def NoSanitizeDocs : Documentation { let Category = DocCatFunction; let Content = [{ -Use the ``no_sanitize`` attribute on a function declaration to specify -that a particular instrumentation or set of instrumentations should not be -applied to that function. The attribute takes a list of string literals, -which have the same meaning as values accepted by the ``-fno-sanitize=`` -flag. For example, ``__attribute__((no_sanitize("address", "thread")))`` -specifies that AddressSanitizer and ThreadSanitizer should not be applied -to the function. +Use the ``no_sanitize`` attribute on a function or a global variable +declaration to specify that a particular instrumentation or set of +instrumentations should not be applied. The attribute takes a list of +string literals, which have the same meaning as values accepted by the +``-fno-sanitize=`` flag. For example, +``__attribute__((no_sanitize("address", "thread")))`` specifies that +AddressSanitizer and ThreadSanitizer should not be applied to the +function or variable. See :ref:`Controlling Code Generation ` for a full list of supported sanitizer flags. @@ -1825,9 +1826,9 @@ let Content = [{ .. _langext-address_sanitizer: -Use ``__attribute__((no_sanitize_address))`` on a function declaration to -specify that address safety instrumentation (e.g. AddressSanitizer) should -not be applied to
[PATCH] D48390: ASan docs: no_sanitize("address") works on globals.
eugenis added a comment. In https://reviews.llvm.org/D48390#1138193, @aaron.ballman wrote: > Do you also want to update AttrDocs.td with some similar information? Done. https://reviews.llvm.org/D48390 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48373: [Driver] Make scudo compatible with -fsanitize-minimal-runtime
eugenis accepted this revision. eugenis added a comment. This revision is now accepted and ready to land. Looks great, thanks! Repository: rC Clang https://reviews.llvm.org/D48373 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48390: ASan docs: no_sanitize("address") works on globals.
This revision was automatically updated to reflect the committed changes. Closed by commit rC335193: ASan docs: no_sanitize("address") works on globals. (authored by eugenis, committed by ). Changed prior to commit: https://reviews.llvm.org/D48390?vs=152140&id=152204#toc Repository: rC Clang https://reviews.llvm.org/D48390 Files: docs/AddressSanitizer.rst include/clang/Basic/AttrDocs.td Index: docs/AddressSanitizer.rst === --- docs/AddressSanitizer.rst +++ docs/AddressSanitizer.rst @@ -197,13 +197,17 @@ Disabling Instrumentation with ``__attribute__((no_sanitize("address")))`` -- -Some code should not be instrumented by AddressSanitizer. One may use the -function attribute ``__attribute__((no_sanitize("address")))`` (which has -deprecated synonyms `no_sanitize_address` and `no_address_safety_analysis`) to -disable instrumentation of a particular function. This attribute may not be -supported by other compilers, so we suggest to use it together with +Some code should not be instrumented by AddressSanitizer. One may use +the attribute ``__attribute__((no_sanitize("address")))`` (which has +deprecated synonyms `no_sanitize_address` and +`no_address_safety_analysis`) to disable instrumentation of a +particular function. This attribute may not be supported by other +compilers, so we suggest to use it together with ``__has_feature(address_sanitizer)``. +The same attribute used on a global variable prevents AddressSanitizer +from adding redzones around it and detecting out of bounds accesses. + Suppressing Errors in Recompiled Code (Blacklist) - Index: include/clang/Basic/AttrDocs.td === --- include/clang/Basic/AttrDocs.td +++ include/clang/Basic/AttrDocs.td @@ -1804,13 +1804,14 @@ def NoSanitizeDocs : Documentation { let Category = DocCatFunction; let Content = [{ -Use the ``no_sanitize`` attribute on a function declaration to specify -that a particular instrumentation or set of instrumentations should not be -applied to that function. The attribute takes a list of string literals, -which have the same meaning as values accepted by the ``-fno-sanitize=`` -flag. For example, ``__attribute__((no_sanitize("address", "thread")))`` -specifies that AddressSanitizer and ThreadSanitizer should not be applied -to the function. +Use the ``no_sanitize`` attribute on a function or a global variable +declaration to specify that a particular instrumentation or set of +instrumentations should not be applied. The attribute takes a list of +string literals, which have the same meaning as values accepted by the +``-fno-sanitize=`` flag. For example, +``__attribute__((no_sanitize("address", "thread")))`` specifies that +AddressSanitizer and ThreadSanitizer should not be applied to the +function or variable. See :ref:`Controlling Code Generation ` for a full list of supported sanitizer flags. @@ -1825,9 +1826,9 @@ let Content = [{ .. _langext-address_sanitizer: -Use ``__attribute__((no_sanitize_address))`` on a function declaration to -specify that address safety instrumentation (e.g. AddressSanitizer) should -not be applied to that function. +Use ``__attribute__((no_sanitize_address))`` on a function or a global +variable declaration to specify that address safety instrumentation +(e.g. AddressSanitizer) should not be applied. }]; } Index: docs/AddressSanitizer.rst === --- docs/AddressSanitizer.rst +++ docs/AddressSanitizer.rst @@ -197,13 +197,17 @@ Disabling Instrumentation with ``__attribute__((no_sanitize("address")))`` -- -Some code should not be instrumented by AddressSanitizer. One may use the -function attribute ``__attribute__((no_sanitize("address")))`` (which has -deprecated synonyms `no_sanitize_address` and `no_address_safety_analysis`) to -disable instrumentation of a particular function. This attribute may not be -supported by other compilers, so we suggest to use it together with +Some code should not be instrumented by AddressSanitizer. One may use +the attribute ``__attribute__((no_sanitize("address")))`` (which has +deprecated synonyms `no_sanitize_address` and +`no_address_safety_analysis`) to disable instrumentation of a +particular function. This attribute may not be supported by other +compilers, so we suggest to use it together with ``__has_feature(address_sanitizer)``. +The same attribute used on a global variable prevents AddressSanitizer +from adding redzones around it and detecting out of bounds accesses. + Suppressing Errors in Recompiled Code (Blacklist) - Index: include/clang/Basic/AttrDocs.td ===
[PATCH] D48454: Ignore blacklist when generating __cfi_check_fail.
eugenis added a comment. Another option is to add a special case to blacklist logic to make it not apply to __cfi_check_fail. Yet another option is to make blacklist not apply to functions without a source location, but that seems to be done intentionally here: http://llvm-cs.pcc.me.uk/tools/clang/lib/CodeGen/CodeGenModule.cpp#1827 https://reviews.llvm.org/D48454 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48454: Ignore blacklist when generating __cfi_check_fail.
eugenis created this revision. eugenis added reviewers: pcc, vlad.tsyrklevich. Fixes PR37898. https://reviews.llvm.org/D48454 Files: clang/lib/CodeGen/CGExpr.cpp clang/test/CodeGen/cfi-check-fail2.c Index: clang/test/CodeGen/cfi-check-fail2.c === --- clang/test/CodeGen/cfi-check-fail2.c +++ clang/test/CodeGen/cfi-check-fail2.c @@ -3,6 +3,12 @@ // RUN: -fsanitize=cfi-vcall \ // RUN: -emit-llvm -o - %s | FileCheck %s +// Check that blacklist does not affect generated code. +// RUN: echo "src:*" > %t-all.blacklist +// RUN: %clang_cc1 -triple x86_64-unknown-linux -O0 -fsanitize-cfi-cross-dso \ +// RUN: -fsanitize=cfi-vcall -fsanitize-blacklist=%t-all.blacklist \ +// RUN: -emit-llvm -o - %s | FileCheck %s + void caller(void (*f)()) { f(); } Index: clang/lib/CodeGen/CGExpr.cpp === --- clang/lib/CodeGen/CGExpr.cpp +++ clang/lib/CodeGen/CGExpr.cpp @@ -3120,11 +3120,16 @@ SanitizerMask Mask = CheckKindMaskPair.second; llvm::Value *Cond = Builder.CreateICmpNE(CheckKind, llvm::ConstantInt::get(Int8Ty, Kind)); -if (CGM.getLangOpts().Sanitize.has(Mask)) +if (CGM.getLangOpts().Sanitize.has(Mask)) { + // This sanitizer may have been disabled in blacklist. This function does + // not have a source location, but "src:*" would still apply. Enable it + // back. + SanOpts.Mask |= Mask; EmitCheck(std::make_pair(Cond, Mask), SanitizerHandler::CFICheckFail, {}, {Data, Addr, ValidVtable}); -else +} else { EmitTrapCheck(Cond); +} } FinishFunction(); Index: clang/test/CodeGen/cfi-check-fail2.c === --- clang/test/CodeGen/cfi-check-fail2.c +++ clang/test/CodeGen/cfi-check-fail2.c @@ -3,6 +3,12 @@ // RUN: -fsanitize=cfi-vcall \ // RUN: -emit-llvm -o - %s | FileCheck %s +// Check that blacklist does not affect generated code. +// RUN: echo "src:*" > %t-all.blacklist +// RUN: %clang_cc1 -triple x86_64-unknown-linux -O0 -fsanitize-cfi-cross-dso \ +// RUN: -fsanitize=cfi-vcall -fsanitize-blacklist=%t-all.blacklist \ +// RUN: -emit-llvm -o - %s | FileCheck %s + void caller(void (*f)()) { f(); } Index: clang/lib/CodeGen/CGExpr.cpp === --- clang/lib/CodeGen/CGExpr.cpp +++ clang/lib/CodeGen/CGExpr.cpp @@ -3120,11 +3120,16 @@ SanitizerMask Mask = CheckKindMaskPair.second; llvm::Value *Cond = Builder.CreateICmpNE(CheckKind, llvm::ConstantInt::get(Int8Ty, Kind)); -if (CGM.getLangOpts().Sanitize.has(Mask)) +if (CGM.getLangOpts().Sanitize.has(Mask)) { + // This sanitizer may have been disabled in blacklist. This function does + // not have a source location, but "src:*" would still apply. Enable it + // back. + SanOpts.Mask |= Mask; EmitCheck(std::make_pair(Cond, Mask), SanitizerHandler::CFICheckFail, {}, {Data, Addr, ValidVtable}); -else +} else { EmitTrapCheck(Cond); +} } FinishFunction(); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48454: Ignore blacklist when generating __cfi_check_fail.
eugenis updated this revision to Diff 152395. eugenis added a comment. Simplify code. https://reviews.llvm.org/D48454 Files: clang/lib/CodeGen/CGExpr.cpp clang/test/CodeGen/cfi-check-fail2.c Index: clang/test/CodeGen/cfi-check-fail2.c === --- clang/test/CodeGen/cfi-check-fail2.c +++ clang/test/CodeGen/cfi-check-fail2.c @@ -3,6 +3,12 @@ // RUN: -fsanitize=cfi-vcall \ // RUN: -emit-llvm -o - %s | FileCheck %s +// Check that blacklist does not affect generated code. +// RUN: echo "src:*" > %t-all.blacklist +// RUN: %clang_cc1 -triple x86_64-unknown-linux -O0 -fsanitize-cfi-cross-dso \ +// RUN: -fsanitize=cfi-vcall -fsanitize-blacklist=%t-all.blacklist \ +// RUN: -emit-llvm -o - %s | FileCheck %s + void caller(void (*f)()) { f(); } Index: clang/lib/CodeGen/CGExpr.cpp === --- clang/lib/CodeGen/CGExpr.cpp +++ clang/lib/CodeGen/CGExpr.cpp @@ -3075,6 +3075,11 @@ StartFunction(GlobalDecl(), CGM.getContext().VoidTy, F, FI, Args, SourceLocation()); + // This function should not be affected by blacklist. This function does + // not have a source location, but "src:*" would still apply. Revert any + // changes to SanOpts made in StartFunction. + SanOpts = CGM.getLangOpts().Sanitize; + llvm::Value *Data = EmitLoadOfScalar(GetAddrOfLocalVar(&ArgData), /*Volatile=*/false, CGM.getContext().VoidPtrTy, ArgData.getLocation()); Index: clang/test/CodeGen/cfi-check-fail2.c === --- clang/test/CodeGen/cfi-check-fail2.c +++ clang/test/CodeGen/cfi-check-fail2.c @@ -3,6 +3,12 @@ // RUN: -fsanitize=cfi-vcall \ // RUN: -emit-llvm -o - %s | FileCheck %s +// Check that blacklist does not affect generated code. +// RUN: echo "src:*" > %t-all.blacklist +// RUN: %clang_cc1 -triple x86_64-unknown-linux -O0 -fsanitize-cfi-cross-dso \ +// RUN: -fsanitize=cfi-vcall -fsanitize-blacklist=%t-all.blacklist \ +// RUN: -emit-llvm -o - %s | FileCheck %s + void caller(void (*f)()) { f(); } Index: clang/lib/CodeGen/CGExpr.cpp === --- clang/lib/CodeGen/CGExpr.cpp +++ clang/lib/CodeGen/CGExpr.cpp @@ -3075,6 +3075,11 @@ StartFunction(GlobalDecl(), CGM.getContext().VoidTy, F, FI, Args, SourceLocation()); + // This function should not be affected by blacklist. This function does + // not have a source location, but "src:*" would still apply. Revert any + // changes to SanOpts made in StartFunction. + SanOpts = CGM.getLangOpts().Sanitize; + llvm::Value *Data = EmitLoadOfScalar(GetAddrOfLocalVar(&ArgData), /*Volatile=*/false, CGM.getContext().VoidPtrTy, ArgData.getLocation()); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48454: Ignore blacklist when generating __cfi_check_fail.
eugenis added a comment. Yes, that's better. https://reviews.llvm.org/D48454 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D48454: Ignore blacklist when generating __cfi_check_fail.
This revision was automatically updated to reflect the committed changes. Closed by commit rL335305: Ignore blacklist when generating __cfi_check_fail. (authored by eugenis, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D48454?vs=152395&id=152400#toc Repository: rL LLVM https://reviews.llvm.org/D48454 Files: cfe/trunk/lib/CodeGen/CGExpr.cpp cfe/trunk/test/CodeGen/cfi-check-fail2.c Index: cfe/trunk/test/CodeGen/cfi-check-fail2.c === --- cfe/trunk/test/CodeGen/cfi-check-fail2.c +++ cfe/trunk/test/CodeGen/cfi-check-fail2.c @@ -3,6 +3,12 @@ // RUN: -fsanitize=cfi-vcall \ // RUN: -emit-llvm -o - %s | FileCheck %s +// Check that blacklist does not affect generated code. +// RUN: echo "src:*" > %t-all.blacklist +// RUN: %clang_cc1 -triple x86_64-unknown-linux -O0 -fsanitize-cfi-cross-dso \ +// RUN: -fsanitize=cfi-vcall -fsanitize-blacklist=%t-all.blacklist \ +// RUN: -emit-llvm -o - %s | FileCheck %s + void caller(void (*f)()) { f(); } Index: cfe/trunk/lib/CodeGen/CGExpr.cpp === --- cfe/trunk/lib/CodeGen/CGExpr.cpp +++ cfe/trunk/lib/CodeGen/CGExpr.cpp @@ -3075,6 +3075,11 @@ StartFunction(GlobalDecl(), CGM.getContext().VoidTy, F, FI, Args, SourceLocation()); + // This function should not be affected by blacklist. This function does + // not have a source location, but "src:*" would still apply. Revert any + // changes to SanOpts made in StartFunction. + SanOpts = CGM.getLangOpts().Sanitize; + llvm::Value *Data = EmitLoadOfScalar(GetAddrOfLocalVar(&ArgData), /*Volatile=*/false, CGM.getContext().VoidPtrTy, ArgData.getLocation()); Index: cfe/trunk/test/CodeGen/cfi-check-fail2.c === --- cfe/trunk/test/CodeGen/cfi-check-fail2.c +++ cfe/trunk/test/CodeGen/cfi-check-fail2.c @@ -3,6 +3,12 @@ // RUN: -fsanitize=cfi-vcall \ // RUN: -emit-llvm -o - %s | FileCheck %s +// Check that blacklist does not affect generated code. +// RUN: echo "src:*" > %t-all.blacklist +// RUN: %clang_cc1 -triple x86_64-unknown-linux -O0 -fsanitize-cfi-cross-dso \ +// RUN: -fsanitize=cfi-vcall -fsanitize-blacklist=%t-all.blacklist \ +// RUN: -emit-llvm -o - %s | FileCheck %s + void caller(void (*f)()) { f(); } Index: cfe/trunk/lib/CodeGen/CGExpr.cpp === --- cfe/trunk/lib/CodeGen/CGExpr.cpp +++ cfe/trunk/lib/CodeGen/CGExpr.cpp @@ -3075,6 +3075,11 @@ StartFunction(GlobalDecl(), CGM.getContext().VoidTy, F, FI, Args, SourceLocation()); + // This function should not be affected by blacklist. This function does + // not have a source location, but "src:*" would still apply. Revert any + // changes to SanOpts made in StartFunction. + SanOpts = CGM.getLangOpts().Sanitize; + llvm::Value *Data = EmitLoadOfScalar(GetAddrOfLocalVar(&ArgData), /*Volatile=*/false, CGM.getContext().VoidPtrTy, ArgData.getLocation()); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38430: Enable -pie and --enable-new-dtags by default on Android.
eugenis marked an inline comment as done. eugenis added inline comments. Comment at: cfe/trunk/lib/Driver/ToolChains/Linux.cpp:814 +bool Linux::isPIEDefault() const { + return (getTriple().isAndroid() && !getTriple().isAndroidVersionLT(16)) || + getSanitizerArgs().requiresPIE(); pcc wrote: > Why only on API level >= 16? If I create an executable targeting an older API > level, it should still work on higher API levels. Because it needs to work on lower API levels, too. I think at some point PIE was actually not supported, so there is no good default that works for everyone. Repository: rL LLVM CHANGES SINCE LAST ACTION https://reviews.llvm.org/D38430/new/ https://reviews.llvm.org/D38430 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D56624: [Sanitizers] UBSan unreachable incompatible with ASan in the presence of `noreturn` calls
eugenis added a comment. > Because "expect_noreturn" calls are allowed to return, the compiler must > behave as they could. In particular, this means that unpoisoning the stack > before expect_noreturn calls (given the current semantics) is premature. I don't think that's true. A hypothetical function maybe_longjmp(jmp_buf env) that checks an opaque condition needs stack unpoisoning before the call, in the absense of a better solution. One possible optimization that I can think of is splitting code after the call into a separate basic block and marking it as cold. Admittedly, that's unlikely to have big impact in practice. I'd guess that [[expect_noreturn]] calls are typically not very hot in the first place. Repository: rL LLVM CHANGES SINCE LAST ACTION https://reviews.llvm.org/D56624/new/ https://reviews.llvm.org/D56624 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D56624: [Sanitizers] UBSan unreachable incompatible with ASan in the presence of `noreturn` calls
eugenis added a comment. > Wouldn’t it be preferable to unpoison the stack inside of maybe_longjmp, once > the opaque condition can be checked? Sure, but that's not always possible. That's why we have interceptors. >> One possible optimization that I can think of is splitting code after the >> call into a separate basic block and marking it as cold. >> Admittedly, that's unlikely to have big impact in practice. I'd guess that >> [[expect_noreturn]] calls are typically not very hot in the first place. > > The cold attribute is already used for this kind of splitting/reordering. I > don't yet see how expect_noreturn creates new opportunities for the optimizer. Strictly speaking, cold attribute on a function means that it is rarely called. It does not say anything about the code after the call being colder than the code before the call (within the same BB), which makes splitting the BB pointless. Anyway, I agree that the arguments [[expect_noreturn]] are not that strong and perhaps don't make the bar for the addition of a new IR attribute. Should we go back to the intrinsic idea? Repository: rL LLVM CHANGES SINCE LAST ACTION https://reviews.llvm.org/D56624/new/ https://reviews.llvm.org/D56624 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D56624: [Sanitizers] UBSan unreachable incompatible with ASan in the presence of `noreturn` calls
eugenis added a comment. Maybe the frontend should insert __asan_handle_noreturn whenever ASan is enabled, and then ASan would not care about the attribute? I'd like to avoid having this logic in two places. Repository: rL LLVM CHANGES SINCE LAST ACTION https://reviews.llvm.org/D56624/new/ https://reviews.llvm.org/D56624 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D57278: [Sanitizers] UBSan unreachable incompatible with ASan in the presence of `noreturn` calls
eugenis accepted this revision. eugenis added a comment. This revision is now accepted and ready to land. LGTM Since the previous iteration of this was controversial, please wait for at least one more review. Repository: rL LLVM CHANGES SINCE LAST ACTION https://reviews.llvm.org/D57278/new/ https://reviews.llvm.org/D57278 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D57278: [Sanitizers] UBSan unreachable incompatible with ASan in the presence of `noreturn` calls
eugenis added a comment. Sounds good. Repository: rL LLVM CHANGES SINCE LAST ACTION https://reviews.llvm.org/D57278/new/ https://reviews.llvm.org/D57278 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D57278: [Sanitizers] UBSan unreachable incompatible with ASan in the presence of `noreturn` calls
eugenis added a comment. LGTM assuming the plan is to add !nosanitize where !noreturn has been, at the original call site, in the follow-up change. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D57278/new/ https://reviews.llvm.org/D57278 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D54330: Driver: Make -fsanitize=shadow-call-stack compatible with -fsanitize-minimal-runtime.
eugenis accepted this revision. eugenis added a comment. This revision is now accepted and ready to land. LGTM Repository: rL LLVM https://reviews.llvm.org/D54330 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D54735: Driver: SCS is compatible with every other sanitizer.
eugenis accepted this revision. eugenis added a comment. This revision is now accepted and ready to land. LGTM Repository: rL LLVM https://reviews.llvm.org/D54735 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D54905: [AddressSanitizer] Add flag to disable linking with CXX runtime
eugenis added a comment. Would turning asan operator new/delete into weak symbols help? CHANGES SINCE LAST ACTION https://reviews.llvm.org/D54905/new/ https://reviews.llvm.org/D54905 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D54905: [AddressSanitizer] Add flag to disable linking with CXX runtime
eugenis added a comment. Our malloc definition is weak already, this will only change new/delete to match. This also makes the behaviour of static runtime consistent with the one of dynamic runtime where we can not prevent user from overloading operator new/delete. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D54905/new/ https://reviews.llvm.org/D54905 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D54905: [AddressSanitizer] Add flag to disable linking with CXX runtime
eugenis added a comment. >> Would turning asan operator new/delete into weak symbols help? > > The new operator is already a weak symbol in libcxx, so it looks like an ODR > violation, doesn't it? I don't think so. It's just symbol interposition. Every module in the process gets the same definition. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D54905/new/ https://reviews.llvm.org/D54905 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D55066: [ASan] Minor documentation fix: remove static linking limitation.
eugenis requested changes to this revision. eugenis added a comment. This revision now requires changes to proceed. Sorry for the delay. This is wrong, static linking is NOT supported. You could be confusing it with static linking of asan runtime library to an executable - that is and has always been the default. Repository: rC Clang CHANGES SINCE LAST ACTION https://reviews.llvm.org/D55066/new/ https://reviews.llvm.org/D55066 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D55066: [ASan] Minor documentation fix: remove static linking limitation.
eugenis added a comment. How about "Static linking of executables is not supported"? Repository: rC Clang CHANGES SINCE LAST ACTION https://reviews.llvm.org/D55066/new/ https://reviews.llvm.org/D55066 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D54905: [AddressSanitizer] Add flag to disable linking with CXX runtime
eugenis added a comment. Linux linkers won't include a member of an archive only because it resolves a weak symbol, so in your example the answer is none. ASan uses -Wl,-whole-archive to pull all its members, this will resolve operator new to ASan definition unless there is another definition in the main executable. In general, the first one in the order of command line arguments will be used. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D54905/new/ https://reviews.llvm.org/D54905 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D55066: [ASan] Minor documentation fix: clarify static linking limitation.
eugenis accepted this revision. eugenis added a comment. This revision is now accepted and ready to land. LGTM Repository: rC Clang CHANGES SINCE LAST ACTION https://reviews.llvm.org/D55066/new/ https://reviews.llvm.org/D55066 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D57711: [Sanitizers] UBSan unreachable incompatible with Kernel ASan
eugenis accepted this revision. eugenis added a comment. LGTM Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D57711/new/ https://reviews.llvm.org/D57711 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D57722: [Clang][NCF] Sanitizer options: helpers to check if {Kernel, Hardware}ASan is enabled
eugenis added a comment. I find the current code more readable than with this change. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D57722/new/ https://reviews.llvm.org/D57722 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26796: [Driver] Use arch type to find compiler-rt libraries (on Linux)
eugenis added a comment. In https://reviews.llvm.org/D26796#853446, @mgorny wrote: > The problems: > > 1. > http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-android/builds/2140/steps/annotate/logs/stdio > -- purely this change, This one still builds i686 libraries. Maybe it needs a clean cmake? Try "clobber" "1" in build properties. [171/178] Linking CXX shared library /var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm_build64/lib/clang/6.0.0/lib/linux/libclang_rt.asan-i686-android.so [172/178] Linking CXX static library /var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm_build64/lib/clang/6.0.0/lib/linux/libclang_rt.asan-i686-android.a > 2. > http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-android/builds/2146/steps/run%20instrumented%20asan%20tests%20%5Bi686%2Ffugu-userdebug%2FN2G48C%5D/logs/stdio > -- after https://reviews.llvm.org/D26764. This probably needs an update of zorg/buildbot/builders/sanitizers/buildbot_android.sh in the zorg repo. Repository: rL LLVM https://reviews.llvm.org/D26796 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26764: [compiler-rt] [cmake] Remove i686 target that is duplicate to i386
eugenis added a comment. I may have underestimated the number of places that will need to be patched because of this change. Perhaps we should restore the special case in the android library name? Repository: rL LLVM https://reviews.llvm.org/D26764 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D26764: [compiler-rt] [cmake] Remove i686 target that is duplicate to i386
eugenis added a comment. IMHO it was a very bad idea to include the "architecture name" (not even a target triple!) in the library path in the first place. No one else does that. GCC made the right choice and called theirs "libasan.so". My plan is to tweak the code that sets the library name to use i686 when the target is i386 and the os is android, both in compiler-rt and in clang. There will be no duplicate targets. Repository: rL LLVM https://reviews.llvm.org/D26764 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37278: Restore clang_rt library name on i686-android.
eugenis created this revision. Herald added a subscriber: srhines. Recent changes canonicalized clang_rt library names to refer to "i386" on all x86 targets. Android historically uses i686. This change adds a special case to keep i686 in all clang_rt libraries when targeting Android. https://reviews.llvm.org/D37278 Files: clang/lib/Driver/ToolChain.cpp clang/test/Driver/sanitizer-ld.c compiler-rt/cmake/Modules/AddCompilerRT.cmake Index: compiler-rt/cmake/Modules/AddCompilerRT.cmake === --- compiler-rt/cmake/Modules/AddCompilerRT.cmake +++ compiler-rt/cmake/Modules/AddCompilerRT.cmake @@ -86,6 +86,14 @@ add_dependencies(compiler-rt ${name}) endfunction() +macro(set_output_name output name arch) + if(ANDROID AND ${arch} STREQUAL "i386") +set(${output} "${name}-i686${COMPILER_RT_OS_SUFFIX}") + else() +set(${output} "${name}-${arch}${COMPILER_RT_OS_SUFFIX}") + endif() +endmacro() + # Adds static or shared runtime for a list of architectures and operating # systems and puts it in the proper directory in the build and install trees. # add_compiler_rt_runtime( @@ -142,15 +150,15 @@ endif() if(type STREQUAL "STATIC") set(libname "${name}-${arch}") -set(output_name_${libname} ${libname}${COMPILER_RT_OS_SUFFIX}) +set_output_name(output_name_${libname} ${name} ${arch}) else() set(libname "${name}-dynamic-${arch}") set(extra_cflags_${libname} ${TARGET_${arch}_CFLAGS} ${LIB_CFLAGS}) set(extra_link_flags_${libname} ${TARGET_${arch}_LINK_FLAGS} ${LIB_LINK_FLAGS}) if(WIN32) - set(output_name_${libname} ${name}_dynamic-${arch}${COMPILER_RT_OS_SUFFIX}) + set_output_name(output_name_${libname} ${name}_dynamic ${arch}) else() - set(output_name_${libname} ${name}-${arch}${COMPILER_RT_OS_SUFFIX}) + set_output_name(output_name_${libname} ${name} ${arch}) endif() endif() set(sources_${libname} ${LIB_SOURCES}) Index: clang/test/Driver/sanitizer-ld.c === --- clang/test/Driver/sanitizer-ld.c +++ clang/test/Driver/sanitizer-ld.c @@ -133,6 +133,18 @@ // CHECK-ASAN-ANDROID-NOT: "-lpthread" // // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -target i686-linux-android -fuse-ld=ld -fsanitize=address \ +// RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \ +// RUN: | FileCheck --check-prefix=CHECK-ASAN-ANDROID-X86 %s +// +// CHECK-ASAN-ANDROID-X86: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}" +// CHECK-ASAN-ANDROID-X86-NOT: "-lc" +// CHECK-ASAN-ANDROID-X86: "-pie" +// CHECK-ASAN-ANDROID-X86-NOT: "-lpthread" +// CHECK-ASAN-ANDROID-X86: libclang_rt.asan-i686-android.so" +// CHECK-ASAN-ANDROID-X86-NOT: "-lpthread" +// +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: -target arm-linux-androideabi -fsanitize=address \ // RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \ // RUN: -shared-libasan \ Index: clang/lib/Driver/ToolChain.cpp === --- clang/lib/Driver/ToolChain.cpp +++ clang/lib/Driver/ToolChain.cpp @@ -305,6 +305,9 @@ ? "armhf" : "arm"; + if (TC.getArch() == llvm::Triple::x86 && Triple.isAndroid()) +return "i686"; + return llvm::Triple::getArchTypeName(TC.getArch()); } Index: compiler-rt/cmake/Modules/AddCompilerRT.cmake === --- compiler-rt/cmake/Modules/AddCompilerRT.cmake +++ compiler-rt/cmake/Modules/AddCompilerRT.cmake @@ -86,6 +86,14 @@ add_dependencies(compiler-rt ${name}) endfunction() +macro(set_output_name output name arch) + if(ANDROID AND ${arch} STREQUAL "i386") +set(${output} "${name}-i686${COMPILER_RT_OS_SUFFIX}") + else() +set(${output} "${name}-${arch}${COMPILER_RT_OS_SUFFIX}") + endif() +endmacro() + # Adds static or shared runtime for a list of architectures and operating # systems and puts it in the proper directory in the build and install trees. # add_compiler_rt_runtime( @@ -142,15 +150,15 @@ endif() if(type STREQUAL "STATIC") set(libname "${name}-${arch}") -set(output_name_${libname} ${libname}${COMPILER_RT_OS_SUFFIX}) +set_output_name(output_name_${libname} ${name} ${arch}) else() set(libname "${name}-dynamic-${arch}") set(extra_cflags_${libname} ${TARGET_${arch}_CFLAGS} ${LIB_CFLAGS}) set(extra_link_flags_${libname} ${TARGET_${arch}_LINK_FLAGS} ${LIB_LINK_FLAGS}) if(WIN32) - set(output_name_${libname} ${name}_dynamic-${arch}${COMPILER_RT_OS_SUFFIX}) + set_output_name(output_name_${libname} ${name}_dynamic ${arch}) else() - set(output_name_${libname} ${name}-${arch}${COMPILER_RT_OS_SUFFIX}) + set_output_name(output_name_
[PATCH] D37278: Restore clang_rt library name on i686-android.
eugenis updated this revision to Diff 113167. eugenis added a comment. +comment https://reviews.llvm.org/D37278 Files: clang/lib/Driver/ToolChain.cpp clang/test/Driver/sanitizer-ld.c compiler-rt/cmake/Modules/AddCompilerRT.cmake Index: compiler-rt/cmake/Modules/AddCompilerRT.cmake === --- compiler-rt/cmake/Modules/AddCompilerRT.cmake +++ compiler-rt/cmake/Modules/AddCompilerRT.cmake @@ -86,6 +86,14 @@ add_dependencies(compiler-rt ${name}) endfunction() +macro(set_output_name output name arch) + if(ANDROID AND ${arch} STREQUAL "i386") +set(${output} "${name}-i686${COMPILER_RT_OS_SUFFIX}") + else() +set(${output} "${name}-${arch}${COMPILER_RT_OS_SUFFIX}") + endif() +endmacro() + # Adds static or shared runtime for a list of architectures and operating # systems and puts it in the proper directory in the build and install trees. # add_compiler_rt_runtime( @@ -142,15 +150,15 @@ endif() if(type STREQUAL "STATIC") set(libname "${name}-${arch}") -set(output_name_${libname} ${libname}${COMPILER_RT_OS_SUFFIX}) +set_output_name(output_name_${libname} ${name} ${arch}) else() set(libname "${name}-dynamic-${arch}") set(extra_cflags_${libname} ${TARGET_${arch}_CFLAGS} ${LIB_CFLAGS}) set(extra_link_flags_${libname} ${TARGET_${arch}_LINK_FLAGS} ${LIB_LINK_FLAGS}) if(WIN32) - set(output_name_${libname} ${name}_dynamic-${arch}${COMPILER_RT_OS_SUFFIX}) + set_output_name(output_name_${libname} ${name}_dynamic ${arch}) else() - set(output_name_${libname} ${name}-${arch}${COMPILER_RT_OS_SUFFIX}) + set_output_name(output_name_${libname} ${name} ${arch}) endif() endif() set(sources_${libname} ${LIB_SOURCES}) Index: clang/test/Driver/sanitizer-ld.c === --- clang/test/Driver/sanitizer-ld.c +++ clang/test/Driver/sanitizer-ld.c @@ -133,6 +133,18 @@ // CHECK-ASAN-ANDROID-NOT: "-lpthread" // // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -target i686-linux-android -fuse-ld=ld -fsanitize=address \ +// RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \ +// RUN: | FileCheck --check-prefix=CHECK-ASAN-ANDROID-X86 %s +// +// CHECK-ASAN-ANDROID-X86: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}" +// CHECK-ASAN-ANDROID-X86-NOT: "-lc" +// CHECK-ASAN-ANDROID-X86: "-pie" +// CHECK-ASAN-ANDROID-X86-NOT: "-lpthread" +// CHECK-ASAN-ANDROID-X86: libclang_rt.asan-i686-android.so" +// CHECK-ASAN-ANDROID-X86-NOT: "-lpthread" +// +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: -target arm-linux-androideabi -fsanitize=address \ // RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \ // RUN: -shared-libasan \ Index: clang/lib/Driver/ToolChain.cpp === --- clang/lib/Driver/ToolChain.cpp +++ clang/lib/Driver/ToolChain.cpp @@ -305,6 +305,10 @@ ? "armhf" : "arm"; + // For historic reasons, Android library is using i686 instead of i386. + if (TC.getArch() == llvm::Triple::x86 && Triple.isAndroid()) +return "i686"; + return llvm::Triple::getArchTypeName(TC.getArch()); } Index: compiler-rt/cmake/Modules/AddCompilerRT.cmake === --- compiler-rt/cmake/Modules/AddCompilerRT.cmake +++ compiler-rt/cmake/Modules/AddCompilerRT.cmake @@ -86,6 +86,14 @@ add_dependencies(compiler-rt ${name}) endfunction() +macro(set_output_name output name arch) + if(ANDROID AND ${arch} STREQUAL "i386") +set(${output} "${name}-i686${COMPILER_RT_OS_SUFFIX}") + else() +set(${output} "${name}-${arch}${COMPILER_RT_OS_SUFFIX}") + endif() +endmacro() + # Adds static or shared runtime for a list of architectures and operating # systems and puts it in the proper directory in the build and install trees. # add_compiler_rt_runtime( @@ -142,15 +150,15 @@ endif() if(type STREQUAL "STATIC") set(libname "${name}-${arch}") -set(output_name_${libname} ${libname}${COMPILER_RT_OS_SUFFIX}) +set_output_name(output_name_${libname} ${name} ${arch}) else() set(libname "${name}-dynamic-${arch}") set(extra_cflags_${libname} ${TARGET_${arch}_CFLAGS} ${LIB_CFLAGS}) set(extra_link_flags_${libname} ${TARGET_${arch}_LINK_FLAGS} ${LIB_LINK_FLAGS}) if(WIN32) - set(output_name_${libname} ${name}_dynamic-${arch}${COMPILER_RT_OS_SUFFIX}) + set_output_name(output_name_${libname} ${name}_dynamic ${arch}) else() - set(output_name_${libname} ${name}-${arch}${COMPILER_RT_OS_SUFFIX}) + set_output_name(output_name_${libname} ${name} ${arch}) endif() endif() set(sources_${libname} ${LIB_SOURCES}) Index: clang/test/Driver
[PATCH] D37278: Restore clang_rt library name on i686-android.
This revision was automatically updated to reflect the committed changes. Closed by commit rL312048: Restore clang_rt library name on i686-android. (authored by eugenis). Changed prior to commit: https://reviews.llvm.org/D37278?vs=113167&id=113170#toc Repository: rL LLVM https://reviews.llvm.org/D37278 Files: cfe/trunk/lib/Driver/ToolChain.cpp cfe/trunk/test/Driver/sanitizer-ld.c compiler-rt/trunk/cmake/Modules/AddCompilerRT.cmake Index: compiler-rt/trunk/cmake/Modules/AddCompilerRT.cmake === --- compiler-rt/trunk/cmake/Modules/AddCompilerRT.cmake +++ compiler-rt/trunk/cmake/Modules/AddCompilerRT.cmake @@ -86,6 +86,14 @@ add_dependencies(compiler-rt ${name}) endfunction() +macro(set_output_name output name arch) + if(ANDROID AND ${arch} STREQUAL "i386") +set(${output} "${name}-i686${COMPILER_RT_OS_SUFFIX}") + else() +set(${output} "${name}-${arch}${COMPILER_RT_OS_SUFFIX}") + endif() +endmacro() + # Adds static or shared runtime for a list of architectures and operating # systems and puts it in the proper directory in the build and install trees. # add_compiler_rt_runtime( @@ -142,15 +150,15 @@ endif() if(type STREQUAL "STATIC") set(libname "${name}-${arch}") -set(output_name_${libname} ${libname}${COMPILER_RT_OS_SUFFIX}) +set_output_name(output_name_${libname} ${name} ${arch}) else() set(libname "${name}-dynamic-${arch}") set(extra_cflags_${libname} ${TARGET_${arch}_CFLAGS} ${LIB_CFLAGS}) set(extra_link_flags_${libname} ${TARGET_${arch}_LINK_FLAGS} ${LIB_LINK_FLAGS}) if(WIN32) - set(output_name_${libname} ${name}_dynamic-${arch}${COMPILER_RT_OS_SUFFIX}) + set_output_name(output_name_${libname} ${name}_dynamic ${arch}) else() - set(output_name_${libname} ${name}-${arch}${COMPILER_RT_OS_SUFFIX}) + set_output_name(output_name_${libname} ${name} ${arch}) endif() endif() set(sources_${libname} ${LIB_SOURCES}) Index: cfe/trunk/test/Driver/sanitizer-ld.c === --- cfe/trunk/test/Driver/sanitizer-ld.c +++ cfe/trunk/test/Driver/sanitizer-ld.c @@ -133,6 +133,18 @@ // CHECK-ASAN-ANDROID-NOT: "-lpthread" // // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -target i686-linux-android -fuse-ld=ld -fsanitize=address \ +// RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \ +// RUN: | FileCheck --check-prefix=CHECK-ASAN-ANDROID-X86 %s +// +// CHECK-ASAN-ANDROID-X86: "{{(.*[^.0-9A-Z_a-z])?}}ld{{(.exe)?}}" +// CHECK-ASAN-ANDROID-X86-NOT: "-lc" +// CHECK-ASAN-ANDROID-X86: "-pie" +// CHECK-ASAN-ANDROID-X86-NOT: "-lpthread" +// CHECK-ASAN-ANDROID-X86: libclang_rt.asan-i686-android.so" +// CHECK-ASAN-ANDROID-X86-NOT: "-lpthread" +// +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: -target arm-linux-androideabi -fsanitize=address \ // RUN: --sysroot=%S/Inputs/basic_android_tree/sysroot \ // RUN: -shared-libasan \ Index: cfe/trunk/lib/Driver/ToolChain.cpp === --- cfe/trunk/lib/Driver/ToolChain.cpp +++ cfe/trunk/lib/Driver/ToolChain.cpp @@ -305,6 +305,10 @@ ? "armhf" : "arm"; + // For historic reasons, Android library is using i686 instead of i386. + if (TC.getArch() == llvm::Triple::x86 && Triple.isAndroid()) +return "i686"; + return llvm::Triple::getArchTypeName(TC.getArch()); } Index: compiler-rt/trunk/cmake/Modules/AddCompilerRT.cmake === --- compiler-rt/trunk/cmake/Modules/AddCompilerRT.cmake +++ compiler-rt/trunk/cmake/Modules/AddCompilerRT.cmake @@ -86,6 +86,14 @@ add_dependencies(compiler-rt ${name}) endfunction() +macro(set_output_name output name arch) + if(ANDROID AND ${arch} STREQUAL "i386") +set(${output} "${name}-i686${COMPILER_RT_OS_SUFFIX}") + else() +set(${output} "${name}-${arch}${COMPILER_RT_OS_SUFFIX}") + endif() +endmacro() + # Adds static or shared runtime for a list of architectures and operating # systems and puts it in the proper directory in the build and install trees. # add_compiler_rt_runtime( @@ -142,15 +150,15 @@ endif() if(type STREQUAL "STATIC") set(libname "${name}-${arch}") -set(output_name_${libname} ${libname}${COMPILER_RT_OS_SUFFIX}) +set_output_name(output_name_${libname} ${name} ${arch}) else() set(libname "${name}-dynamic-${arch}") set(extra_cflags_${libname} ${TARGET_${arch}_CFLAGS} ${LIB_CFLAGS}) set(extra_link_flags_${libname} ${TARGET_${arch}_LINK_FLAGS} ${LIB_LINK_FLAGS}) if(WIN32) - set(output_name_${libname} ${name}_dynamic-${arch}${COMPILER_RT_OS_SUFFIX}) + set_output_name(output_name_${libname} ${name}_dynamic ${
[PATCH] D26764: [compiler-rt] [cmake] Remove i686 target that is duplicate to i386
eugenis added a comment. I've landed the android special case in r312048 Repository: rL LLVM https://reviews.llvm.org/D26764 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37656: [cfi] Set function attributes for __cfi_* functions.
eugenis created this revision. Herald added subscribers: hiraditya, kristof.beyls, srhines, aemerson. Set target_cpu and target_features attributes on __cfi_check_fail and __cfi_check. Make cfi_check use Thumb encoding on ARM target. https://reviews.llvm.org/D37656 Files: clang/lib/CodeGen/CGExpr.cpp clang/test/CodeGen/cfi-check-thumb.c llvm/lib/Transforms/IPO/CrossDSOCFI.cpp llvm/test/Transforms/CrossDSOCFI/thumb.ll Index: llvm/test/Transforms/CrossDSOCFI/thumb.ll === --- llvm/test/Transforms/CrossDSOCFI/thumb.ll +++ /dev/null @@ -1,22 +0,0 @@ -; RUN: opt -mtriple=armv7-linux-android -S -cross-dso-cfi < %s | FileCheck --check-prefix=THUMB %s -; RUN: opt -mtriple=thumbv7-linux-android -S -cross-dso-cfi < %s | FileCheck --check-prefix=THUMB %s -; RUN: opt -mtriple=i386-linux -S -cross-dso-cfi < %s | FileCheck --check-prefix=NOTHUMB %s -; RUN: opt -mtriple=x86_64-linux -S -cross-dso-cfi < %s | FileCheck --check-prefix=NOTHUMB %s - -target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64" - -define signext i8 @f() !type !0 !type !1 { -entry: - ret i8 1 -} - -!llvm.module.flags = !{!2} - -!0 = !{i64 0, !"_ZTSFcvE"} -!1 = !{i64 0, i64 111} -!2 = !{i32 4, !"Cross-DSO CFI", i32 1} - -; THUMB: define void @__cfi_check({{.*}} #[[A:.*]] align 4096 -; THUMB: attributes #[[A]] = { {{.*}}"target-features"="+thumb-mode" - -; NOTHUMB: define void @__cfi_check({{.*}} align 4096 Index: llvm/lib/Transforms/IPO/CrossDSOCFI.cpp === --- llvm/lib/Transforms/IPO/CrossDSOCFI.cpp +++ llvm/lib/Transforms/IPO/CrossDSOCFI.cpp @@ -117,10 +117,6 @@ F->deleteBody(); F->setAlignment(4096); - Triple T(M.getTargetTriple()); - if (T.isARM() || T.isThumb()) -F->addFnAttr("target-features", "+thumb-mode"); - auto args = F->arg_begin(); Value &CallSiteTypeId = *(args++); CallSiteTypeId.setName("CallSiteTypeId"); Index: clang/test/CodeGen/cfi-check-thumb.c === --- /dev/null +++ clang/test/CodeGen/cfi-check-thumb.c @@ -0,0 +1,18 @@ +// Test that __cfi_check and __cfi_check_fail have common attributes and calling convention. +// Also __cfi_check is always using Thumb encoding. +// RUN: %clang_cc1 -triple arm-unknown-linux -O0 -fsanitize-cfi-cross-dso \ +// RUN: -fsanitize=cfi-vcall \ +// RUN: -emit-llvm -o - %s | FileCheck --check-prefixes=CHECK,CHECK-ARM %s +// +// RUN: %clang_cc1 -triple thumb-unknown-linux -O0 -fsanitize-cfi-cross-dso \ +// RUN: -fsanitize=cfi-vcall \ +// RUN: -emit-llvm -o - %s | FileCheck --check-prefixes=CHECK,CHECK-THUMB %s +// +// REQUIRES: arm-registered-target + +// CHECK-ARM: define weak_odr hidden void @__cfi_check_fail(i8*, i8*) #[[ARM:.*]] { +// CHECK-THUMB: define weak_odr hidden void @__cfi_check_fail(i8*, i8*) #[[THUMB:.*]] { +// CHECK: define weak void @__cfi_check(i64, i8*, i8*) #[[THUMB:.*]] { + +// CHECK-ARM: attributes #[[ARM]] = {{.*}}"target-features"="{{.*}}-thumb-mode +// CHECK: attributes #[[THUMB]] = {{.*}}"target-features"="{{.*}}+thumb-mode Index: clang/lib/CodeGen/CGExpr.cpp === --- clang/lib/CodeGen/CGExpr.cpp +++ clang/lib/CodeGen/CGExpr.cpp @@ -2912,6 +2912,33 @@ EmitBlock(Cont); } +static void AddTargetAttributes(llvm::AttrBuilder &Builder, +CodeGenFunction &CGF, llvm::Function *F, +bool ForceThumb) { + StringRef TargetCPU = CGF.getTarget().getTargetOpts().CPU; + if (TargetCPU != "") +Builder.addAttribute("target-cpu", TargetCPU); + + std::vector &DefaultFeatures = + CGF.getTarget().getTargetOpts().Features; + const auto &Triple = CGF.getTarget().getTriple(); + SmallVector Features; + Features.reserve(DefaultFeatures.size() + ForceThumb); + if (ForceThumb && (Triple.isARM() || Triple.isThumb())) { +for (auto &S : DefaultFeatures) + if (S != "-thumb-mode" && S != "+thumb-mode") +Features.push_back(S); +Features.push_back("+thumb-mode"); + } else { +for (auto &S : DefaultFeatures) + Features.push_back(S); + } + + std::sort(Features.begin(), Features.end()); + Builder.addAttribute("target-features", + llvm::join(Features.begin(), Features.end(), ",")); +} + // Emit a stub for __cfi_check function so that the linker knows about this // symbol in LTO mode. void CodeGenFunction::EmitCfiCheckStub() { @@ -2928,6 +2955,15 @@ llvm::CallInst::Create( llvm::Intrinsic::getDeclaration(M, llvm::Intrinsic::trap), "", BB); llvm::ReturnInst::Create(Ctx, nullptr, BB); + + // Set default target-cpu and target-features, but force thumb encoding if + // applicable. Note that we don't want the whole set of default function + // attributes as SetLLVMFunctionAttributes sets. In particular, __cfi_check + // must use the default calling convention
[PATCH] D37871: [ASAN] Add macro denoting availability of new `__asan_handle_no_return()` function.
eugenis added a comment. This function was added to the header recently, but it has been provided by ASan runtime library since the beginning. Why not simply declare it in libc++abi? https://reviews.llvm.org/D37871 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37867: [MSan] Add flag to disable use-after-dtor.
eugenis added a comment. Have you looked at performance? https://reviews.llvm.org/D37867 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37867: [MSan] Add flag to disable use-after-dtor.
eugenis accepted this revision. eugenis added a comment. Oh right, I was looking at https://reviews.llvm.org/D37860. https://reviews.llvm.org/D37867 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37860: [MSan] Enable use-after-dtor instrumentation by default.
eugenis added a comment. Looking at __sanitizer_dtor_callback implementation, this change will add a (fast) stack unwind in every destructor. In extreme cases (like a tight loop doing string operations) it could be bad for performance. I've seen ~15% AFAIR. https://reviews.llvm.org/D37860 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37925: Allow specifying sanitizers in blacklists
eugenis added inline comments. Comment at: include/clang/Basic/SanitizerSpecialCaseList.h:33 + + bool inSection(SanitizerMask Mask, StringRef Prefix, StringRef Query, + StringRef Category = StringRef()) const; Please add a comment on the meaning of Mask. I assume it's any-of? Comment at: lib/CodeGen/CodeGenModule.cpp:1569 const auto &SanitizerBL = getContext().getSanitizerBlacklist(); - if (SanitizerBL.isBlacklistedGlobal(GV->getName(), Category)) + if (SanitizerBL.isBlacklistedGlobal(ASanMask, GV->getName(), Category)) return true; would this blacklist [address] when compiling for kernel-address, and vice versa? Comment at: test/CodeGen/sanitizer-special-case-list.c:4 +// RUN: echo "fun:*cfi*" > %t.unsanitized1 +// RUN: echo "fun:*overflow*" >> %t.unsanitized1 +// RUN: %clang_cc1 -fsanitize=unsigned-integer-overflow,cfi-icall -fsanitize-blacklist=%t.unsanitized1 -emit-llvm %s -o - | FileCheck %s --check-prefix=UNSANITIZED it is common to add such files as actual files under Inputs/ https://reviews.llvm.org/D37925 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37925: Allow specifying sanitizers in blacklists
eugenis added inline comments. Comment at: docs/SanitizerSpecialCaseList.rst:57 + +Sections are regular expressions written in square brackets that denote which +sanitizer the following entries apply to. For example, ``[address]`` specifies Section names are regular expressions also, not really a regular expression, more like a wildcard; I don't know what's the right term for this Comment at: lib/CodeGen/CGDeclCXX.cpp:322 + if (getLangOpts().Sanitize.hasOneOf(ASanMask)) +if (!isInSanitizerBlacklist(ASanMask, Fn, Loc)) Fn->addFnAttr(llvm::Attribute::SanitizeAddress); vlad.tsyrklevich wrote: > This use of ASanMask could also confound address & kernel-address as @eugenis > pointed out. It would be more readable to split it in two if-s, IMHO: one for asan, one for kernel-asan. https://reviews.llvm.org/D37925 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38063: [MSan] Disable sanitization for __sanitizer_dtor_callback.
eugenis added a comment. A test, please. Comment at: clang/lib/CodeGen/CGClass.cpp:1592 + llvm::CallInst *I = CGF.EmitNounwindRuntimeCall(Fn, Args); + I->setMetadata("nosanitize", llvm::MDNode::get(CGF.getLLVMContext(), + llvm::None)); Use SanitizerScope. https://reviews.llvm.org/D38063 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D38063: [MSan] Disable sanitization for __sanitizer_dtor_callback.
eugenis accepted this revision. eugenis added a comment. This revision is now accepted and ready to land. Please also add a tiny LLVM test that call instructions with nosanitize metadata are not instrumented. https://reviews.llvm.org/D38063 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37925: Allow specifying sanitizers in blacklists
eugenis added a subscriber: dberris. eugenis added inline comments. Comment at: include/clang/Basic/SanitizerSpecialCaseList.h:39 + // Initialize SanitizerSections. + void sanitizerCompile(); + "compile" in this method name is confusing. It's used in the base class to refer to regexp compilation. Let's call this one createSanitizerSections. Comment at: lib/AST/Decl.cpp:3932 ASTContext &Context = getASTContext(); - if (!Context.getLangOpts().Sanitize.hasOneOf( - SanitizerKind::Address | SanitizerKind::KernelAddress) || + const SanitizerMask ASanMask = + SanitizerKind::Address | SanitizerKind::KernelAddress; "Asan" is a more common spelling in clang & compiler-rt identifiers (even though official abbreviation is ASan). Comment at: lib/AST/Decl.cpp:3953 ReasonToReject = 5; // is standard layout. - else if (Blacklist.isBlacklistedLocation(getLocation(), "field-padding")) + else if (Blacklist.isBlacklistedLocation(ASanMask, getLocation(), + "field-padding")) Looks like this is another case of missing "& LangOpts.Sanitize.Mask" ? Comment at: lib/Basic/XRayLists.cpp:29 // whether it's treated as a "never" instrument function. - if (AlwaysInstrument->inSection("fun", FunctionName, "arg1")) + if (AlwaysInstrument->inSection("xray_always_instrument", "fun", FunctionName, + "arg1")) It feels redundant to have AlwaysInstrument and NeverInstrument lists, and then the same distinction in section names. Maybe sections could be named "xray" in both cases? Or, better, the lists could be merged into a single list with always and never sections? There is also an issue of backward compatibility. Anyway, that's for xray devs to decide. @dberris Comment at: lib/CodeGen/CodeGenModule.cpp:1564 // For now globals can be blacklisted only in ASan and KASan. - if (!LangOpts.Sanitize.hasOneOf( - SanitizerKind::Address | SanitizerKind::KernelAddress)) + const SanitizerMask ASanMask = + SanitizerKind::Address | SanitizerKind::KernelAddress; AsanMask https://reviews.llvm.org/D37925 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37656: [cfi] Set function attributes for __cfi_* functions.
eugenis added a comment. ping https://reviews.llvm.org/D37656 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37656: [cfi] Set function attributes for __cfi_* functions.
eugenis added inline comments. Comment at: clang/lib/CodeGen/CGExpr.cpp:2917 +CodeGenFunction &CGF, llvm::Function *F, +bool ForceThumb) { + StringRef TargetCPU = CGF.getTarget().getTargetOpts().CPU; echristo wrote: > I don't think we should be force setting thumb anywhere, it should be handled > on a function by function basis the way we do all of the target attribute > stuff. We want this function to be Thumb even if the rest of the module is ARM. It lets us use 2x less memory in the implementation of __cfi_slowpath here: https://clang.llvm.org/docs/ControlFlowIntegrityDesign.html#cfi-slowpath This function does not have source, so it can not have target attributes, too. Are you suggesting faking a piece of AST (FunctionDecl with attached attributes) and then using the regular attribute setting code? Comment at: clang/lib/CodeGen/CGExpr.cpp:2961-2963 + // attributes as SetLLVMFunctionAttributes sets. In particular, __cfi_check + // must use the default calling convention for the platform. ABI-changing + // flags like -mhard-float should not affect __cfi_check. echristo wrote: > This is odd. Can you explain this a bit more? __cfi_check is called from compiler-rt or libdl.so, so it can not have any fancy calling convention. It must use what's standard on the platform. OK, __cfi_check has no floating-point parameters, so -mhard-float would not be a problem. https://reviews.llvm.org/D37656 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D61479: Finish "Adapt -fsanitize=function to SANITIZER_NON_UNIQUE_TYPEINFO"
eugenis added inline comments. Comment at: clang/docs/UndefinedBehaviorSanitizer.rst:207 +equivalence by pointer, not also by name (even on platforms that would +otherwise fall back to checking equivalence by name). I don't think this is true. As far as I can see, __ubsan_handle_function_type_mismatch in the minimal runtime simply prints a report and exits, i.e. -fsanitize=function is incompatible and should be rejected by the driver. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D61479/new/ https://reviews.llvm.org/D61479 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D63967: Handle IntToPtr in isBytewiseValue
eugenis accepted this revision. eugenis added a comment. This revision is now accepted and ready to land. LGTM Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D63967/new/ https://reviews.llvm.org/D63967 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D64169: ARM MTE stack sanitizer.
eugenis updated this revision to Diff 209578. eugenis marked 4 inline comments as done. eugenis added a comment. addressed review comments Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D64169/new/ https://reviews.llvm.org/D64169 Files: clang/include/clang/Basic/Features.def clang/include/clang/Basic/Sanitizers.def clang/lib/CodeGen/CGDeclCXX.cpp clang/lib/CodeGen/CodeGenFunction.cpp clang/lib/CodeGen/CodeGenModule.cpp clang/lib/CodeGen/SanitizerMetadata.cpp clang/lib/Driver/SanitizerArgs.cpp clang/lib/Driver/ToolChains/Linux.cpp clang/test/CodeGen/memtag-attr.cpp clang/test/Driver/fsanitize.c clang/test/Lexer/has_feature_memtag_sanitizer.cpp clang/test/SemaCXX/attr-no-sanitize.cpp llvm/docs/BitCodeFormat.rst llvm/docs/LangRef.rst llvm/include/llvm/Bitcode/LLVMBitCodes.h llvm/include/llvm/IR/Attributes.td llvm/lib/AsmParser/LLLexer.cpp llvm/lib/AsmParser/LLParser.cpp llvm/lib/AsmParser/LLToken.h llvm/lib/Bitcode/Reader/BitcodeReader.cpp llvm/lib/Bitcode/Writer/BitcodeWriter.cpp llvm/lib/IR/Attributes.cpp llvm/lib/IR/Verifier.cpp llvm/lib/Transforms/IPO/ForceFunctionAttrs.cpp llvm/lib/Transforms/Utils/CodeExtractor.cpp llvm/test/Bitcode/attributes.ll llvm/test/Transforms/Inline/attributes.ll llvm/utils/emacs/llvm-mode.el Index: llvm/utils/emacs/llvm-mode.el === --- llvm/utils/emacs/llvm-mode.el +++ llvm/utils/emacs/llvm-mode.el @@ -26,7 +26,7 @@ "inaccessiblemem_or_argmemonly" "inlinehint" "jumptable" "minsize" "naked" "nobuiltin" "noduplicate" "noimplicitfloat" "noinline" "nonlazybind" "noredzone" "noreturn" "norecurse" "nounwind" "optnone" "optsize" "readnone" "readonly" "returns_twice" - "speculatable" "ssp" "sspreq" "sspstrong" "safestack" "sanitize_address" "sanitize_hwaddress" + "speculatable" "ssp" "sspreq" "sspstrong" "safestack" "sanitize_address" "sanitize_hwaddress" "sanitize_memtag" "sanitize_thread" "sanitize_memory" "strictfp" "uwtable" "writeonly" "immarg") 'symbols) . font-lock-constant-face) ;; Variables '("%[-a-zA-Z$._][-a-zA-Z$._0-9]*" . font-lock-variable-name-face) Index: llvm/test/Transforms/Inline/attributes.ll === --- llvm/test/Transforms/Inline/attributes.ll +++ llvm/test/Transforms/Inline/attributes.ll @@ -22,6 +22,10 @@ ret i32 %i } +define i32 @sanitize_memtag_callee(i32 %i) sanitize_memtag { + ret i32 %i +} + define i32 @safestack_callee(i32 %i) safestack { ret i32 %i } @@ -50,6 +54,10 @@ ret i32 %i } +define i32 @alwaysinline_sanitize_memtag_callee(i32 %i) alwaysinline sanitize_memtag { + ret i32 %i +} + define i32 @alwaysinline_safestack_callee(i32 %i) alwaysinline safestack { ret i32 %i } @@ -104,6 +112,17 @@ ; CHECK-NEXT: ret i32 } +define i32 @test_no_sanitize_memtag(i32 %arg) { + %x1 = call i32 @noattr_callee(i32 %arg) + %x2 = call i32 @sanitize_memtag_callee(i32 %x1) + %x3 = call i32 @alwaysinline_callee(i32 %x2) + %x4 = call i32 @alwaysinline_sanitize_memtag_callee(i32 %x3) + ret i32 %x4 +; CHECK-LABEL: @test_no_sanitize_memtag( +; CHECK-NEXT: @sanitize_memtag_callee +; CHECK-NEXT: ret i32 +} + ; Check that: ; * noattr callee is not inlined into sanitize_(address|memory|thread) caller, @@ -154,6 +173,17 @@ ; CHECK-NEXT: ret i32 } +define i32 @test_sanitize_memtag(i32 %arg) sanitize_memtag { + %x1 = call i32 @noattr_callee(i32 %arg) + %x2 = call i32 @sanitize_memtag_callee(i32 %x1) + %x3 = call i32 @alwaysinline_callee(i32 %x2) + %x4 = call i32 @alwaysinline_sanitize_memtag_callee(i32 %x3) + ret i32 %x4 +; CHECK-LABEL: @test_sanitize_memtag( +; CHECK-NEXT: @noattr_callee +; CHECK-NEXT: ret i32 +} + define i32 @test_safestack(i32 %arg) safestack { %x1 = call i32 @noattr_callee(i32 %arg) %x2 = call i32 @safestack_callee(i32 %x1) Index: llvm/test/Bitcode/attributes.ll === --- llvm/test/Bitcode/attributes.ll +++ llvm/test/Bitcode/attributes.ll @@ -204,7 +204,7 @@ ; CHECK: define void @f34() { call void @nobuiltin() nobuiltin -; CHECK: call void @nobuiltin() #39 +; CHECK: call void @nobuiltin() #40 ret void; } @@ -368,6 +368,12 @@ ret void } +; CHECK: define void @f63() #39 +define void @f63() sanitize_memtag +{ + ret void; +} + ; CHECK: attributes #0 = { noreturn } ; CHECK: attributes #1 = { nounwind } ; CHECK: attributes #2 = { readnone } @@ -407,4 +413,5 @@ ; CHECK: attributes #36 = { willreturn } ; CHECK: attributes #37 = { nofree } ; CHECK: attributes #38 = { nosync } -; CHECK: attributes #39 = { nobuiltin } +; CHECK: attributes #39 = { sanitize_memtag } +; CHECK: attributes #40 = { nobuiltin } Index: llvm/lib/Transforms/Utils/CodeExtractor.cpp === --- llvm/lib/Transform
[PATCH] D64169: ARM MTE stack sanitizer.
eugenis added inline comments. Comment at: clang/lib/CodeGen/SanitizerMetadata.cpp:28 + if (!CGM.getLangOpts().Sanitize.hasOneOf( + SanitizerKind::Address | SanitizerKind::KernelAddress | + SanitizerKind::HWAddress | SanitizerKind::KernelHWAddress | vitalybuka wrote: > maybe shared constant or function for : > SanitizerKind::Address | SanitizerKind::KernelAddress | > SanitizerKind::HWAddress | SanitizerKind::KernelHWAddress | > SanitizerKind::MemTag added a helper function Comment at: llvm/docs/BitCodeFormat.rst:1060 * code 58: ``shadowcallstack`` +* code 62: ``sanitize_memtag`` vitalybuka wrote: > why it's 62 and not e.g. 59? Because people forget to update this file. And it's 64 already. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D64169/new/ https://reviews.llvm.org/D64169 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D61479: Finish "Adapt -fsanitize=function to SANITIZER_NON_UNIQUE_TYPEINFO"
eugenis accepted this revision. eugenis added a comment. This revision is now accepted and ready to land. LGTM, but please update the summary: An alternative would be to disallow -fsanitize=function ... CHANGES SINCE LAST ACTION https://reviews.llvm.org/D61479/new/ https://reviews.llvm.org/D61479 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D64169: ARM MTE stack sanitizer.
This revision was automatically updated to reflect the committed changes. Closed by commit rL366123: ARM MTE stack sanitizer. (authored by eugenis, committed by ). Changed prior to commit: https://reviews.llvm.org/D64169?vs=209578&id=209936#toc Repository: rL LLVM CHANGES SINCE LAST ACTION https://reviews.llvm.org/D64169/new/ https://reviews.llvm.org/D64169 Files: cfe/trunk/include/clang/Basic/Features.def cfe/trunk/include/clang/Basic/Sanitizers.def cfe/trunk/lib/CodeGen/CGDeclCXX.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.cpp cfe/trunk/lib/CodeGen/CodeGenModule.cpp cfe/trunk/lib/CodeGen/SanitizerMetadata.cpp cfe/trunk/lib/Driver/SanitizerArgs.cpp cfe/trunk/lib/Driver/ToolChains/Linux.cpp cfe/trunk/test/CodeGen/memtag-attr.cpp cfe/trunk/test/Driver/fsanitize.c cfe/trunk/test/Lexer/has_feature_memtag_sanitizer.cpp cfe/trunk/test/SemaCXX/attr-no-sanitize.cpp llvm/trunk/docs/BitCodeFormat.rst llvm/trunk/docs/LangRef.rst llvm/trunk/include/llvm/Bitcode/LLVMBitCodes.h llvm/trunk/include/llvm/IR/Attributes.td llvm/trunk/lib/AsmParser/LLLexer.cpp llvm/trunk/lib/AsmParser/LLParser.cpp llvm/trunk/lib/AsmParser/LLToken.h llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp llvm/trunk/lib/IR/Attributes.cpp llvm/trunk/lib/IR/Verifier.cpp llvm/trunk/lib/Transforms/IPO/ForceFunctionAttrs.cpp llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp llvm/trunk/test/Bitcode/attributes.ll llvm/trunk/test/Transforms/Inline/attributes.ll llvm/trunk/utils/emacs/llvm-mode.el Index: llvm/trunk/lib/AsmParser/LLLexer.cpp === --- llvm/trunk/lib/AsmParser/LLLexer.cpp +++ llvm/trunk/lib/AsmParser/LLLexer.cpp @@ -679,6 +679,7 @@ KEYWORD(shadowcallstack); KEYWORD(sanitize_address); KEYWORD(sanitize_hwaddress); + KEYWORD(sanitize_memtag); KEYWORD(sanitize_thread); KEYWORD(sanitize_memory); KEYWORD(speculative_load_hardening); Index: llvm/trunk/lib/AsmParser/LLParser.cpp === --- llvm/trunk/lib/AsmParser/LLParser.cpp +++ llvm/trunk/lib/AsmParser/LLParser.cpp @@ -1311,6 +1311,8 @@ B.addAttribute(Attribute::SanitizeAddress); break; case lltok::kw_sanitize_hwaddress: B.addAttribute(Attribute::SanitizeHWAddress); break; +case lltok::kw_sanitize_memtag: + B.addAttribute(Attribute::SanitizeMemTag); break; case lltok::kw_sanitize_thread: B.addAttribute(Attribute::SanitizeThread); break; case lltok::kw_sanitize_memory: @@ -1668,6 +1670,7 @@ case lltok::kw_returns_twice: case lltok::kw_sanitize_address: case lltok::kw_sanitize_hwaddress: +case lltok::kw_sanitize_memtag: case lltok::kw_sanitize_memory: case lltok::kw_sanitize_thread: case lltok::kw_speculative_load_hardening: @@ -1766,6 +1769,7 @@ case lltok::kw_returns_twice: case lltok::kw_sanitize_address: case lltok::kw_sanitize_hwaddress: +case lltok::kw_sanitize_memtag: case lltok::kw_sanitize_memory: case lltok::kw_sanitize_thread: case lltok::kw_speculative_load_hardening: Index: llvm/trunk/lib/AsmParser/LLToken.h === --- llvm/trunk/lib/AsmParser/LLToken.h +++ llvm/trunk/lib/AsmParser/LLToken.h @@ -176,6 +176,7 @@ kw_argmemonly, kw_sanitize_address, kw_sanitize_hwaddress, + kw_sanitize_memtag, kw_builtin, kw_byval, kw_inalloca, Index: llvm/trunk/lib/IR/Attributes.cpp === --- llvm/trunk/lib/IR/Attributes.cpp +++ llvm/trunk/lib/IR/Attributes.cpp @@ -283,6 +283,8 @@ return "sanitize_address"; if (hasAttribute(Attribute::SanitizeHWAddress)) return "sanitize_hwaddress"; + if (hasAttribute(Attribute::SanitizeMemTag)) +return "sanitize_memtag"; if (hasAttribute(Attribute::AlwaysInline)) return "alwaysinline"; if (hasAttribute(Attribute::ArgMemOnly)) Index: llvm/trunk/lib/IR/Verifier.cpp === --- llvm/trunk/lib/IR/Verifier.cpp +++ llvm/trunk/lib/IR/Verifier.cpp @@ -1516,6 +1516,7 @@ case Attribute::ReturnsTwice: case Attribute::SanitizeAddress: case Attribute::SanitizeHWAddress: + case Attribute::SanitizeMemTag: case Attribute::SanitizeThread: case Attribute::SanitizeMemory: case Attribute::MinSize: Index: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp === --- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp +++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp @@ -1296,6 +1296,9 @@ case Attribute::AllocSize: llvm_unreachable("allocsize not supported in raw format"); break; + case Attribute::SanitizeMemTag: +llvm_unreachable("sanitize_memtag attribute not supported in raw format"); +break; } llvm_un
[PATCH] D64843: hwasan: Initialize the pass only once.
eugenis added a subscriber: chandlerc. eugenis added a comment. I don't know what is the best practice here. Other sanitizers have both module and function passes, is there a reason to do things differently here? @chandlerc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D64843/new/ https://reviews.llvm.org/D64843 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D64843: hwasan: Initialize the pass only once.
eugenis accepted this revision. eugenis added a comment. This revision is now accepted and ready to land. OK, sure. As I understand functon passes also have better data locality by running a sequence of passes over a single function. Not sure how important that is. LGTM Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D64843/new/ https://reviews.llvm.org/D64843 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D65629: cfi-icall: Allow the jump table to be optionally made non-canonical.
eugenis added inline comments. Comment at: clang/test/CodeGen/cfi-icall-canonical-jump-tables.c:15 +// CHECK: define void @g({{.*}} [[ATTR2:#[0-9]+]] +__attribute__((cfi_jump_table_canonical)) void g() {} + would it be more natural to spell it "cfi_canonical_jump_table" ? No strong feelings one way or the other. Comment at: clang/test/SemaCXX/attr-cfi-jump-table-canonical.cpp:3 + +__attribute__((cfi_jump_table_canonical)) void f() {} + Test the new attribute on function declaration. Comment at: llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp:328 +if (lowertypetests::isJumpTableCanonical(&F)) Linkage = CFL_Definition; +else if (F.hasExternalWeakLinkage()) Is this correct? Looks like it would cause function definitions with non-canonical jump tables to be exported as declarations. This could be desirable for LowerTypeTests, but could it affect other users negatively? Comment at: llvm/test/Transforms/ThinLTOBitcodeWriter/cfi-functions-canonical-jump-tables.ll:4 + +; CHECK: !"f1", i8 1 +; CHECK: !"f2", i8 1 Does this test check exported functions metadata? Could you add a check for the metadata name, or at least a comment to make this easier to understand in the future? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D65629/new/ https://reviews.llvm.org/D65629 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D65629: cfi-icall: Allow the jump table to be optionally made non-canonical.
eugenis accepted this revision. eugenis added a comment. This revision is now accepted and ready to land. LGTM Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D65629/new/ https://reviews.llvm.org/D65629 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D64169: ARM MTE stack sanitizer.
eugenis created this revision. eugenis added reviewers: pcc, hctim, vitalybuka, ostannard. Herald added subscribers: dexonsmith, steven_wu, cryptoad, hiraditya, kristof.beyls, javed.absar, mehdi_amini, srhines. Herald added projects: clang, LLVM. Add "memtag" sanitizer that detects and mitigates stack memory issues using armv8.5 Memory Tagging Extension. It is similar in principle to HWASan, which is a software implementation of the same idea, but there are enough differencies to warrant a new sanitizer type IMHO. It is also expected to have very different performance properties. The new sanitizer does not have a runtime library (it may grow one later, along with a "debugging" mode). Similar to SafeStack and StackProtector, the instrumentation pass (in a follow up change) will be inserted in all cases, but will only affect functions marked with the new sanitize_memtag attribute. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D64169 Files: clang/include/clang/Basic/Features.def clang/include/clang/Basic/Sanitizers.def clang/lib/CodeGen/CGDeclCXX.cpp clang/lib/CodeGen/CodeGenFunction.cpp clang/lib/CodeGen/CodeGenModule.cpp clang/lib/CodeGen/SanitizerMetadata.cpp clang/lib/Driver/SanitizerArgs.cpp clang/lib/Driver/ToolChains/Linux.cpp clang/test/CodeGen/memtag-attr.cpp clang/test/Driver/fsanitize.c clang/test/Lexer/has_feature_memtag_sanitizer.cpp clang/test/SemaCXX/attr-no-sanitize.cpp llvm/docs/BitCodeFormat.rst llvm/docs/LangRef.rst llvm/include/llvm/Bitcode/LLVMBitCodes.h llvm/include/llvm/IR/Attributes.td llvm/lib/AsmParser/LLLexer.cpp llvm/lib/AsmParser/LLParser.cpp llvm/lib/AsmParser/LLToken.h llvm/lib/Bitcode/Reader/BitcodeReader.cpp llvm/lib/Bitcode/Writer/BitcodeWriter.cpp llvm/lib/IR/Attributes.cpp llvm/lib/IR/Verifier.cpp llvm/lib/Transforms/IPO/ForceFunctionAttrs.cpp llvm/lib/Transforms/Utils/CodeExtractor.cpp llvm/test/Bitcode/attributes.ll llvm/test/Transforms/Inline/attributes.ll llvm/utils/emacs/llvm-mode.el Index: llvm/utils/emacs/llvm-mode.el === --- llvm/utils/emacs/llvm-mode.el +++ llvm/utils/emacs/llvm-mode.el @@ -26,7 +26,7 @@ "inaccessiblemem_or_argmemonly" "inlinehint" "jumptable" "minsize" "naked" "nobuiltin" "noduplicate" "noimplicitfloat" "noinline" "nonlazybind" "noredzone" "noreturn" "norecurse" "nounwind" "optnone" "optsize" "readnone" "readonly" "returns_twice" - "speculatable" "ssp" "sspreq" "sspstrong" "safestack" "sanitize_address" "sanitize_hwaddress" + "speculatable" "ssp" "sspreq" "sspstrong" "safestack" "sanitize_address" "sanitize_hwaddress" "sanitize_memtag" "sanitize_thread" "sanitize_memory" "strictfp" "uwtable" "writeonly" "immarg") 'symbols) . font-lock-constant-face) ;; Variables '("%[-a-zA-Z$._][-a-zA-Z$._0-9]*" . font-lock-variable-name-face) Index: llvm/test/Transforms/Inline/attributes.ll === --- llvm/test/Transforms/Inline/attributes.ll +++ llvm/test/Transforms/Inline/attributes.ll @@ -22,6 +22,10 @@ ret i32 %i } +define i32 @sanitize_memtag_callee(i32 %i) sanitize_memtag { + ret i32 %i +} + define i32 @safestack_callee(i32 %i) safestack { ret i32 %i } @@ -50,6 +54,10 @@ ret i32 %i } +define i32 @alwaysinline_sanitize_memtag_callee(i32 %i) alwaysinline sanitize_memtag { + ret i32 %i +} + define i32 @alwaysinline_safestack_callee(i32 %i) alwaysinline safestack { ret i32 %i } @@ -104,6 +112,17 @@ ; CHECK-NEXT: ret i32 } +define i32 @test_no_sanitize_memtag(i32 %arg) { + %x1 = call i32 @noattr_callee(i32 %arg) + %x2 = call i32 @sanitize_memtag_callee(i32 %x1) + %x3 = call i32 @alwaysinline_callee(i32 %x2) + %x4 = call i32 @alwaysinline_sanitize_memtag_callee(i32 %x3) + ret i32 %x4 +; CHECK-LABEL: @test_no_sanitize_memtag( +; CHECK-NEXT: @sanitize_memtag_callee +; CHECK-NEXT: ret i32 +} + ; Check that: ; * noattr callee is not inlined into sanitize_(address|memory|thread) caller, @@ -154,6 +173,17 @@ ; CHECK-NEXT: ret i32 } +define i32 @test_sanitize_memtag(i32 %arg) sanitize_memtag { + %x1 = call i32 @noattr_callee(i32 %arg) + %x2 = call i32 @sanitize_memtag_callee(i32 %x1) + %x3 = call i32 @alwaysinline_callee(i32 %x2) + %x4 = call i32 @alwaysinline_sanitize_memtag_callee(i32 %x3) + ret i32 %x4 +; CHECK-LABEL: @test_sanitize_memtag( +; CHECK-NEXT: @noattr_callee +; CHECK-NEXT: ret i32 +} + define i32 @test_safestack(i32 %arg) safestack { %x1 = call i32 @noattr_callee(i32 %arg) %x2 = call i32 @safestack_callee(i32 %x1) Index: llvm/test/Bitcode/attributes.ll === --- llvm/test/Bitcode/attributes.ll +++ llvm/test/Bitcode/attributes.ll @@ -204,7 +204,7 @@ ; CHECK: define void @f34() { call void @nobuiltin() nobuiltin -; CHECK: call void @nobuiltin() #37 +; CHECK: call voi
[PATCH] D64169: ARM MTE stack sanitizer.
eugenis updated this revision to Diff 207920. eugenis added a comment. fix bitcode docs Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D64169/new/ https://reviews.llvm.org/D64169 Files: clang/include/clang/Basic/Features.def clang/include/clang/Basic/Sanitizers.def clang/lib/CodeGen/CGDeclCXX.cpp clang/lib/CodeGen/CodeGenFunction.cpp clang/lib/CodeGen/CodeGenModule.cpp clang/lib/CodeGen/SanitizerMetadata.cpp clang/lib/Driver/SanitizerArgs.cpp clang/lib/Driver/ToolChains/Linux.cpp clang/test/CodeGen/memtag-attr.cpp clang/test/Driver/fsanitize.c clang/test/Lexer/has_feature_memtag_sanitizer.cpp clang/test/SemaCXX/attr-no-sanitize.cpp llvm/docs/BitCodeFormat.rst llvm/docs/LangRef.rst llvm/include/llvm/Bitcode/LLVMBitCodes.h llvm/include/llvm/IR/Attributes.td llvm/lib/AsmParser/LLLexer.cpp llvm/lib/AsmParser/LLParser.cpp llvm/lib/AsmParser/LLToken.h llvm/lib/Bitcode/Reader/BitcodeReader.cpp llvm/lib/Bitcode/Writer/BitcodeWriter.cpp llvm/lib/IR/Attributes.cpp llvm/lib/IR/Verifier.cpp llvm/lib/Transforms/IPO/ForceFunctionAttrs.cpp llvm/lib/Transforms/Utils/CodeExtractor.cpp llvm/test/Bitcode/attributes.ll llvm/test/Transforms/Inline/attributes.ll llvm/utils/emacs/llvm-mode.el Index: llvm/utils/emacs/llvm-mode.el === --- llvm/utils/emacs/llvm-mode.el +++ llvm/utils/emacs/llvm-mode.el @@ -26,7 +26,7 @@ "inaccessiblemem_or_argmemonly" "inlinehint" "jumptable" "minsize" "naked" "nobuiltin" "noduplicate" "noimplicitfloat" "noinline" "nonlazybind" "noredzone" "noreturn" "norecurse" "nounwind" "optnone" "optsize" "readnone" "readonly" "returns_twice" - "speculatable" "ssp" "sspreq" "sspstrong" "safestack" "sanitize_address" "sanitize_hwaddress" + "speculatable" "ssp" "sspreq" "sspstrong" "safestack" "sanitize_address" "sanitize_hwaddress" "sanitize_memtag" "sanitize_thread" "sanitize_memory" "strictfp" "uwtable" "writeonly" "immarg") 'symbols) . font-lock-constant-face) ;; Variables '("%[-a-zA-Z$._][-a-zA-Z$._0-9]*" . font-lock-variable-name-face) Index: llvm/test/Transforms/Inline/attributes.ll === --- llvm/test/Transforms/Inline/attributes.ll +++ llvm/test/Transforms/Inline/attributes.ll @@ -22,6 +22,10 @@ ret i32 %i } +define i32 @sanitize_memtag_callee(i32 %i) sanitize_memtag { + ret i32 %i +} + define i32 @safestack_callee(i32 %i) safestack { ret i32 %i } @@ -50,6 +54,10 @@ ret i32 %i } +define i32 @alwaysinline_sanitize_memtag_callee(i32 %i) alwaysinline sanitize_memtag { + ret i32 %i +} + define i32 @alwaysinline_safestack_callee(i32 %i) alwaysinline safestack { ret i32 %i } @@ -104,6 +112,17 @@ ; CHECK-NEXT: ret i32 } +define i32 @test_no_sanitize_memtag(i32 %arg) { + %x1 = call i32 @noattr_callee(i32 %arg) + %x2 = call i32 @sanitize_memtag_callee(i32 %x1) + %x3 = call i32 @alwaysinline_callee(i32 %x2) + %x4 = call i32 @alwaysinline_sanitize_memtag_callee(i32 %x3) + ret i32 %x4 +; CHECK-LABEL: @test_no_sanitize_memtag( +; CHECK-NEXT: @sanitize_memtag_callee +; CHECK-NEXT: ret i32 +} + ; Check that: ; * noattr callee is not inlined into sanitize_(address|memory|thread) caller, @@ -154,6 +173,17 @@ ; CHECK-NEXT: ret i32 } +define i32 @test_sanitize_memtag(i32 %arg) sanitize_memtag { + %x1 = call i32 @noattr_callee(i32 %arg) + %x2 = call i32 @sanitize_memtag_callee(i32 %x1) + %x3 = call i32 @alwaysinline_callee(i32 %x2) + %x4 = call i32 @alwaysinline_sanitize_memtag_callee(i32 %x3) + ret i32 %x4 +; CHECK-LABEL: @test_sanitize_memtag( +; CHECK-NEXT: @noattr_callee +; CHECK-NEXT: ret i32 +} + define i32 @test_safestack(i32 %arg) safestack { %x1 = call i32 @noattr_callee(i32 %arg) %x2 = call i32 @safestack_callee(i32 %x1) Index: llvm/test/Bitcode/attributes.ll === --- llvm/test/Bitcode/attributes.ll +++ llvm/test/Bitcode/attributes.ll @@ -204,7 +204,7 @@ ; CHECK: define void @f34() { call void @nobuiltin() nobuiltin -; CHECK: call void @nobuiltin() #37 +; CHECK: call void @nobuiltin() #38 ret void; } @@ -357,6 +357,12 @@ ret void } +; CHECK: define void @f61() #37 +define void @f61() sanitize_memtag +{ +ret void; +} + ; CHECK: attributes #0 = { noreturn } ; CHECK: attributes #1 = { nounwind } ; CHECK: attributes #2 = { readnone } @@ -394,4 +400,5 @@ ; CHECK: attributes #34 = { sanitize_hwaddress } ; CHECK: attributes #35 = { shadowcallstack } ; CHECK: attributes #36 = { willreturn } -; CHECK: attributes #37 = { nobuiltin } +; CHECK: attributes #37 = { sanitize_memtag } +; CHECK: attributes #38 = { nobuiltin } Index: llvm/lib/Transforms/Utils/CodeExtractor.cpp === --- llvm/lib/Transforms/Utils/CodeExtrac
[PATCH] D63908: hwasan: Improve precision of checks using short granule tags.
eugenis added inline comments. Comment at: compiler-rt/lib/hwasan/hwasan_allocator.cpp:159 ? (t ? t->GenerateRandomTag() : kFallbackAllocTag) : 0; +uptr tag_size = orig_size ? orig_size : 1; When !(flags()->tag_in_malloc && malloc_bisect(stack, orig_size)), the tail tag should be 0 as well. Comment at: compiler-rt/lib/hwasan/hwasan_checks.h:69 +return true; + if (mem_tag > 15) +return false; s/15/kShadowAlignment -1/ Comment at: compiler-rt/lib/hwasan/hwasan_checks.h:113 + if (UNLIKELY(tail_sz != 0 && !PossiblyShortTagMatches( + *shadow_last, end & ~0xfull, tail_sz))) { +SigTrap<0x20 * (EA == ErrorAction::Recover) + 0xfull, nice :) A named constant please. Comment at: llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp:1195 + auto *NewAI = new AllocaInst( + TypeWithPadding, AI->getType()->getAddressSpace(), nullptr, "", AI); + NewAI->takeName(AI); Good. I think we will need to do the same in MTE patches, but for different reason. There is something in BasicAA that thinks that a store of size 16 (in MachineInstr) can not possibly alias with a smaller alloca, so simply increasing alloca alignment is not enough. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D63908/new/ https://reviews.llvm.org/D63908 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D63908: hwasan: Improve precision of checks using short granule tags.
eugenis accepted this revision. eugenis added a comment. This revision is now accepted and ready to land. LGTM Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D63908/new/ https://reviews.llvm.org/D63908 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D64385: GodeGen, NFC: Add test to track emitStoresForConstant behavior
eugenis accepted this revision. eugenis added a comment. This revision is now accepted and ready to land. LGTM Comment at: clang/test/CodeGen/init-memset.c:36 + int a[16] = {0, 0, 1}; + // CHECK: call void @llvm.memset.{{.*}} + // CHECK: store i32 1 Would it be useful to check the range of the memset? I.e. does it overlap with the following store or not. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D64385/new/ https://reviews.llvm.org/D64385 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D63854: [NFC] Convert large lambda into method
eugenis accepted this revision. eugenis added a comment. This revision is now accepted and ready to land. LGTM if it's really NFC Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D63854/new/ https://reviews.llvm.org/D63854 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D63940: [NFC] Pass DataLayout into isBytewiseValue
eugenis accepted this revision. eugenis added a comment. This revision is now accepted and ready to land. LGTM Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D63940/new/ https://reviews.llvm.org/D63940 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D60593: [GwpAsan] Introduce GWP-ASan.
eugenis added a comment. Ha, I think it matches LLVM perfectly :) G, of course, stands for "Galaxy". Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D60593/new/ https://reviews.llvm.org/D60593 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D61923: [GWP-ASan] Mutex implementation [2].
eugenis added a comment. I think the idea is that implementing our own spinlock is not much harder than having 3 platform-specific implementations (posix, window, fuchsia). Also, scudo_standalone is doing the same ( @cryptoad, why? ). As Mitch mentioned, we should move the implementation into a common directory. Why not do this now? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D61923/new/ https://reviews.llvm.org/D61923 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D61923: [GWP-ASan] Mutex implementation [2].
eugenis added inline comments. Comment at: compiler-rt/lib/gwp_asan/mutex.h:27 +private: +#include "gwp_asan/platform_specific/mutex_members.inc" +}; What's the point of this include? You are leaking platform details into this common header anyway. We can make the interface C-only; or use pImpl to hide the implementation; or just move the entire declaration of Mutex to the platform header. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D61923/new/ https://reviews.llvm.org/D61923 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D61923: [GWP-ASan] Mutex implementation [2].
eugenis added inline comments. Comment at: compiler-rt/lib/gwp_asan/platform_specific/mutex_posix.cpp:43 + +Mutex::Mutex() : PImpl(new Impl) {} +Mutex::~Mutex() { delete PImpl; } This is a dependency on libc++ / libstdc++. I'm not sure about using malloc() inside mutex constructor, either. We will probably want the mutex to be linker-initialized, too. AFAIK, gwp-asan would not have any clear initialization entry point, and would need to do this lazily in malloc, which can there be several of, concurrently. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D61923/new/ https://reviews.llvm.org/D61923 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits