From 50faaf111ee68154e4c3d03a14e0c6dc4db17215 Mon Sep 17 00:00:00 2001 From: Mark Mentovai Date: Thu, 22 Aug 2024 04:02:29 +0000 Subject: [PATCH] Revert "Don't redefine macros from base/compiler_specific.h." MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 458bdec9852280f091a72f9d90eb75f04d0af05f. Reason for revert: Crashpad roll into Chrommium failed. https://chromium-review.googlesource.com/c/5805903 https://ci.chromium.org/ui/p/chromium/builders/try/android-x64-rel/171929/ https://logs.chromium.org/logs/chromium/buildbucket/cr-buildbucket/8738938901079891665/+/u/compile__with_patch_/stdout While linking libcrashpad_handler_trampoline.so: ``` ld.lld: error: undefined symbol: std::__Cr::__libcpp_verbose_abort(char const*, ...) >>> referenced by ascii.cc >>> obj/third_party/abseil-cpp/absl/strings/strings/ascii.o:(std::__Cr::__throw_out_of_range(char const*)) >>> referenced by lightweight_quarantine.cc >>> allocator_core/lightweight_quarantine.o:(partition_alloc::internal::LightweightQuarantineBranch::~LightweightQuarantineBranch()) in archive obj/base/allocator/partition_allocator/src/partition_alloc/liballocator_core.a >>> referenced by lightweight_quarantine.cc >>> allocator_core/lightweight_quarantine.o:(partition_alloc::internal::LightweightQuarantineBranch::Purge()) in archive obj/base/allocator/partition_allocator/src/partition_alloc/liballocator_core.a >>> referenced 1 more times […] ld.lld: error: undefined symbol: std::get_new_handler() […] ld.lld: error: undefined symbol: _Unwind_Backtrace […] ld.lld: error: undefined symbol: _Unwind_GetIP […] ld.lld: error: undefined symbol: __cxa_guard_acquire […] ld.lld: error: undefined symbol: __cxa_guard_release […] clang++: error: linker command failed with exit code 1 (use -v to see invocation) ``` Original change's description: > Don't redefine macros from base/compiler_specific.h. > > `DISABLE_CFI_ICALL` is already defined in that header; use it. > > This is both simpler and less likely to trigger macro redefinition > errors. > > Bug: none > Change-Id: I3ecfe9b6dc4ac42c6a69b3fd9c6d2c68fe8e62a2 > Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/5805458 > Reviewed-by: Mark Mentovai Bug: none Change-Id: Ie225e03e07ab3d0a00933217b377cee14fcdb8b7 No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/5806223 Reviewed-by: Mark Mentovai Commit-Queue: Joshua Peraza Reviewed-by: Joshua Peraza --- util/BUILD.gn | 5 +---- util/misc/no_cfi_icall.h | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/util/BUILD.gn b/util/BUILD.gn index 8d037fea..d4f4b2d0 100644 --- a/util/BUILD.gn +++ b/util/BUILD.gn @@ -730,10 +730,7 @@ if (!crashpad_is_android && !crashpad_is_ios) { source_set("no_cfi_icall") { sources = [ "misc/no_cfi_icall.h" ] public_configs = [ "..:crashpad_config" ] - public_deps = [ - "$mini_chromium_source_parent:base", - "$mini_chromium_source_parent:build", - ] + public_deps = [ "$mini_chromium_source_parent:build" ] } source_set("util_test") { diff --git a/util/misc/no_cfi_icall.h b/util/misc/no_cfi_icall.h index 7410026d..bb3e5940 100644 --- a/util/misc/no_cfi_icall.h +++ b/util/misc/no_cfi_icall.h @@ -18,7 +18,6 @@ #include #include -#include "base/compiler_specific.h" #include "build/build_config.h" #if BUILDFLAG(IS_WIN) @@ -29,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 BUILDFLAG(IS_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;