Merge "[make] Add memtag-stack sanitizer, switch to linker-generated notes." am: 739ff268d5 am: ce0f195722 am: b58c03598d

Original change: https://android-review.googlesource.com/c/platform/build/+/2199541

Change-Id: I5a6d1cf05930930d423888ebbd37811fd5bc0a57
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Florian Mayer
2022-08-31 19:56:01 +00:00
committed by Automerger Merge Worker

View File

@@ -161,9 +161,11 @@ ifeq ($(strip $(ENABLE_CFI)),false)
my_sanitize_diag := $(filter-out cfi,$(my_sanitize_diag)) my_sanitize_diag := $(filter-out cfi,$(my_sanitize_diag))
endif endif
# Also disable CFI if ASAN is enabled. # Also disable CFI and MTE if ASAN is enabled.
ifneq ($(filter address,$(my_sanitize)),) ifneq ($(filter address,$(my_sanitize)),)
my_sanitize := $(filter-out cfi,$(my_sanitize)) my_sanitize := $(filter-out cfi,$(my_sanitize))
my_sanitize := $(filter-out memtag_stack,$(my_sanitize))
my_sanitize := $(filter-out memtag_heap,$(my_sanitize))
my_sanitize_diag := $(filter-out cfi,$(my_sanitize_diag)) my_sanitize_diag := $(filter-out cfi,$(my_sanitize_diag))
endif endif
@@ -205,10 +207,13 @@ endif
ifneq ($(filter arm x86 x86_64,$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)),) ifneq ($(filter arm x86 x86_64,$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)),)
my_sanitize := $(filter-out hwaddress,$(my_sanitize)) my_sanitize := $(filter-out hwaddress,$(my_sanitize))
my_sanitize := $(filter-out memtag_heap,$(my_sanitize)) my_sanitize := $(filter-out memtag_heap,$(my_sanitize))
my_sanitize := $(filter-out memtag_stack,$(my_sanitize))
endif endif
ifneq ($(filter hwaddress,$(my_sanitize)),) ifneq ($(filter hwaddress,$(my_sanitize)),)
my_sanitize := $(filter-out address,$(my_sanitize)) my_sanitize := $(filter-out address,$(my_sanitize))
my_sanitize := $(filter-out memtag_stack,$(my_sanitize))
my_sanitize := $(filter-out memtag_heap,$(my_sanitize))
my_sanitize := $(filter-out thread,$(my_sanitize)) my_sanitize := $(filter-out thread,$(my_sanitize))
my_sanitize := $(filter-out cfi,$(my_sanitize)) my_sanitize := $(filter-out cfi,$(my_sanitize))
endif endif
@@ -224,21 +229,27 @@ ifneq ($(filter hwaddress,$(my_sanitize)),)
endif endif
endif endif
ifneq ($(filter memtag_heap,$(my_sanitize)),) ifneq ($(filter memtag_heap memtag_stack,$(my_sanitize)),)
# Add memtag ELF note. ifneq ($(filter memtag_heap,$(my_sanitize_diag)),)
ifneq ($(filter EXECUTABLES NATIVE_TESTS,$(LOCAL_MODULE_CLASS)),) my_cflags += -fsanitize-memtag-mode=sync
ifneq ($(filter memtag_heap,$(my_sanitize_diag)),) my_sanitize_diag := $(filter-out memtag_heap,$(my_sanitize_diag))
my_whole_static_libraries += note_memtag_heap_sync else
else my_cflags += -fsanitize-memtag-mode=async
my_whole_static_libraries += note_memtag_heap_async
endif
endif endif
# This is all that memtag_heap does - it is not an actual -fsanitize argument. endif
# Remove it from the list.
ifneq ($(filter memtag_heap,$(my_sanitize)),)
my_cflags += -fsanitize=memtag-heap
my_sanitize := $(filter-out memtag_heap,$(my_sanitize)) my_sanitize := $(filter-out memtag_heap,$(my_sanitize))
endif endif
my_sanitize_diag := $(filter-out memtag_heap,$(my_sanitize_diag)) ifneq ($(filter memtag_stack,$(my_sanitize)),)
my_cflags += -fsanitize=memtag-stack
my_cflags += -march=armv8a+memtag
my_ldflags += -march=armv8a+memtag
my_asflags += -march=armv8a+memtag
my_sanitize := $(filter-out memtag_stack,$(my_sanitize))
endif
# TSAN is not supported on 32-bit architectures. For non-multilib cases, make # 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. # its use an error. For multilib cases, don't use it for the 32-bit case.