From 36d4bb83b3d79dc85c35c258a9364f7d6ec0f6b3 Mon Sep 17 00:00:00 2001 From: Joshua Peraza Date: Mon, 21 Sep 2020 13:42:59 -0700 Subject: [PATCH] Remove base dependency from no_cfi_icall crashpad_handler_trampoline needs to use NoCfiIcall, but does not link libstdc++ in order to remain small. A dependency on base causes link errors in ASAN builds: https://ci.chromium.org/p/chromium/builders/ci/android-asan/7791? This CL depends on https://chromium-review.googlesource.com/c/chromium/mini_chromium/+/2405651 in order to include "build/build_config.h". Change-Id: Ie0344b7ead9c019cdda8a6e37ea8ec9cd5bf72b0 Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2405650 Commit-Queue: Joshua Peraza Reviewed-by: Mark Mentovai --- DEPS | 2 +- compat/BUILD.gn | 4 ++++ third_party/mini_chromium/BUILD.gn | 12 ++++++++++++ util/BUILD.gn | 2 +- util/misc/no_cfi_icall.h | 22 ++++++++++++++++++---- 5 files changed, 36 insertions(+), 6 deletions(-) diff --git a/DEPS b/DEPS index 46f233f2..83995e0c 100644 --- a/DEPS +++ b/DEPS @@ -42,7 +42,7 @@ deps = { '7bde79cc274d06451bf65ae82c012a5d3e476b5a', 'crashpad/third_party/mini_chromium/mini_chromium': Var('chromium_git') + '/chromium/mini_chromium@' + - '68da43e59f7ebcf39625fcef3a5303fc06240b42', + '76a9bb7475f6217eaf108789246379d3972b4e6a', 'crashpad/third_party/libfuzzer/src': Var('chromium_git') + '/chromium/llvm-project/compiler-rt/lib/fuzzer.git@' + 'fda403cf93ecb8792cb1d061564d89a6553ca020', diff --git a/compat/BUILD.gn b/compat/BUILD.gn index 65c9b85a..9bb2306f 100644 --- a/compat/BUILD.gn +++ b/compat/BUILD.gn @@ -164,6 +164,10 @@ compat_target("compat") { "..:crashpad_config", ] + if (!crashpad_is_win) { + public_deps = [ "../third_party/mini_chromium:base" ] + } + deps = [ "../util:no_cfi_icall" ] if (!crashpad_is_mac) { diff --git a/third_party/mini_chromium/BUILD.gn b/third_party/mini_chromium/BUILD.gn index 48adc797..3efd7105 100644 --- a/third_party/mini_chromium/BUILD.gn +++ b/third_party/mini_chromium/BUILD.gn @@ -33,3 +33,15 @@ group("base_test_support") { public_deps = [ "//base/test:test_support" ] } } + +group("build") { + if (crashpad_is_in_chromium) { + # Chromium has no build target. + } else if (crashpad_is_standalone || crashpad_is_in_fuchsia) { + public_deps = [ "mini_chromium/build" ] + } else if (crashpad_is_external) { + public_deps = [ "../../../../mini_chromium/mini_chromium/build" ] + } else if (crashpad_is_in_dart) { + public_deps = [ "//third_party/mini_chromium/mini_chromium/build" ] + } +} diff --git a/util/BUILD.gn b/util/BUILD.gn index f35b840b..0ce83599 100644 --- a/util/BUILD.gn +++ b/util/BUILD.gn @@ -669,8 +669,8 @@ if (!crashpad_is_android && !crashpad_is_ios) { # without cycles. source_set("no_cfi_icall") { sources = [ "misc/no_cfi_icall.h" ] - public_deps = [ "../third_party/mini_chromium:base" ] public_configs = [ "..:crashpad_config" ] + public_deps = [ "../third_party/mini_chromium:build" ] } source_set("util_test") { diff --git a/util/misc/no_cfi_icall.h b/util/misc/no_cfi_icall.h index ebc632c5..0d131e57 100644 --- a/util/misc/no_cfi_icall.h +++ b/util/misc/no_cfi_icall.h @@ -18,8 +18,6 @@ #include #include -#include "base/compiler_specific.h" -#include "base/macros.h" #include "build/build_config.h" #if defined(OS_WIN) @@ -30,6 +28,24 @@ namespace crashpad { namespace { +// Sanitizers annotations. +#if defined(__has_attribute) +#if __has_attribute(no_sanitize) +#define NO_SANITIZE(what) __attribute__((no_sanitize(what))) +#endif +#endif +#if !defined(NO_SANITIZE) +#define NO_SANITIZE(what) +#endif + +// DISABLE_CFI_ICALL -- Disable Control Flow Integrity indirect call checks. +#if defined(OS_WIN) +// Windows also needs __declspec(guard(nocf)). +#define DISABLE_CFI_ICALL NO_SANITIZE("cfi-icall") __declspec(guard(nocf)) +#else +#define DISABLE_CFI_ICALL NO_SANITIZE("cfi-icall") +#endif + template struct FunctorTraits; @@ -116,8 +132,6 @@ class NoCfiIcall { private: Functor function_; - - DISALLOW_COPY_AND_ASSIGN(NoCfiIcall); }; } // namespace crashpad