Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8520f4b1 authored by Mitch Phillips's avatar Mitch Phillips
Browse files

[MTE] [gnu make] Add memtag_globals as a sanitizer target.

GNU make bits for https://android-review.git.corp.google.com/c/platform/build/soong/+/2625692.

Bug: N/A
Test: Build {libc, libm, libc++, libm, and libnetd} in internal master
with these patches and an experimental compiler with the lld support.
Also, `SANITIZE_TARGET=memtag_globals m` here with in-tree compiler
without lld support.

Change-Id: I44c239ba907a90a355c46e12afbbbe96bb2e4426
parent 4f6a18d4
Loading
Loading
Loading
Loading
+14 −3
Original line number Diff line number Diff line
@@ -176,6 +176,7 @@ endif
ifneq ($(filter address,$(my_sanitize)),)
  my_sanitize := $(filter-out cfi,$(my_sanitize))
  my_sanitize := $(filter-out memtag_stack,$(my_sanitize))
  my_sanitize := $(filter-out memtag_globals,$(my_sanitize))
  my_sanitize := $(filter-out memtag_heap,$(my_sanitize))
  my_sanitize_diag := $(filter-out cfi,$(my_sanitize_diag))
endif
@@ -183,8 +184,8 @@ endif
# Disable memtag for host targets. Host executables in AndroidMk files are
# deprecated, but some partners still have them floating around.
ifdef LOCAL_IS_HOST_MODULE
  my_sanitize := $(filter-out memtag_heap memtag_stack,$(my_sanitize))
  my_sanitize_diag := $(filter-out memtag_heap memtag_stack,$(my_sanitize_diag))
  my_sanitize := $(filter-out memtag_heap memtag_stack memtag_globals,$(my_sanitize))
  my_sanitize_diag := $(filter-out memtag_heap memtag_stack memtag_globals,$(my_sanitize_diag))
endif

# Disable sanitizers which need the UBSan runtime for host targets.
@@ -219,11 +220,13 @@ ifneq ($(filter arm x86 x86_64,$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)),)
  my_sanitize := $(filter-out hwaddress,$(my_sanitize))
  my_sanitize := $(filter-out memtag_heap,$(my_sanitize))
  my_sanitize := $(filter-out memtag_stack,$(my_sanitize))
  my_sanitize := $(filter-out memtag_globals,$(my_sanitize))
endif

ifneq ($(filter hwaddress,$(my_sanitize)),)
  my_sanitize := $(filter-out address,$(my_sanitize))
  my_sanitize := $(filter-out memtag_stack,$(my_sanitize))
  my_sanitize := $(filter-out memtag_globals,$(my_sanitize))
  my_sanitize := $(filter-out memtag_heap,$(my_sanitize))
  my_sanitize := $(filter-out thread,$(my_sanitize))
  my_sanitize := $(filter-out cfi,$(my_sanitize))
@@ -240,7 +243,7 @@ ifneq ($(filter hwaddress,$(my_sanitize)),)
  endif
endif

ifneq ($(filter memtag_heap memtag_stack,$(my_sanitize)),)
ifneq ($(filter memtag_heap memtag_stack memtag_globals,$(my_sanitize)),)
  ifneq ($(filter memtag_heap,$(my_sanitize_diag)),)
    my_cflags += -fsanitize-memtag-mode=sync
    my_sanitize_diag := $(filter-out memtag_heap,$(my_sanitize_diag))
@@ -262,6 +265,14 @@ ifneq ($(filter memtag_stack,$(my_sanitize)),)
  my_sanitize := $(filter-out memtag_stack,$(my_sanitize))
endif

ifneq ($(filter memtag_globals,$(my_sanitize)),)
  my_cflags += -fsanitize=memtag-globals
  # TODO(mitchp): For now, enable memtag-heap with memtag-globals because the
  # linker isn't new enough
  # (https://reviews.llvm.org/differential/changeset/?ref=4243566).
  my_sanitize := $(filter-out memtag_globals,$(my_sanitize))
endif

# TSAN is not supported on 32-bit architectures. For non-multilib cases, make
# its use an error. For multilib cases, don't use it for the 32-bit case.
ifneq ($(filter thread,$(my_sanitize)),)