From 8566eb0ee81cf1d60f8ad4f798335144b537ccac Mon Sep 17 00:00:00 2001 From: Evgenii Stepanov Date: Thu, 1 Feb 2024 11:34:59 -0800 Subject: [PATCH] Add missing linker flags for memtag sanitizers. This fixes a discrepancy between Make and Soong build systems. Memtag sanitizers rely on the linker to mark the executable as requesting heap/stack/globals tagging. Test: readelf -n | grep .note.android.memtag Bug: 322107634 Change-Id: I4a25509ff280e25d14576157903a2bbf162a4895 --- core/config_sanitizers.mk | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/core/config_sanitizers.mk b/core/config_sanitizers.mk index 3507961833..ab2d5c1ddf 100644 --- a/core/config_sanitizers.mk +++ b/core/config_sanitizers.mk @@ -261,10 +261,10 @@ endif ifneq ($(filter memtag_heap memtag_stack memtag_globals,$(my_sanitize)),) ifneq ($(filter memtag_heap,$(my_sanitize_diag)),) - my_cflags += -fsanitize-memtag-mode=sync + my_ldflags += -fsanitize-memtag-mode=sync my_sanitize_diag := $(filter-out memtag_heap,$(my_sanitize_diag)) else - my_cflags += -fsanitize-memtag-mode=async + my_ldflags += -fsanitize-memtag-mode=async endif endif @@ -277,11 +277,13 @@ endif ifneq ($(filter memtag_heap,$(my_sanitize)),) my_cflags += -fsanitize=memtag-heap + my_ldflags += -fsanitize=memtag-heap my_sanitize := $(filter-out memtag_heap,$(my_sanitize)) endif ifneq ($(filter memtag_stack,$(my_sanitize)),) my_cflags += -fsanitize=memtag-stack + my_ldflags += -fsanitize=memtag-stack my_cflags += -march=armv8a+memtag my_ldflags += -march=armv8a+memtag my_asflags += -march=armv8a+memtag @@ -290,6 +292,7 @@ endif ifneq ($(filter memtag_globals,$(my_sanitize)),) my_cflags += -fsanitize=memtag-globals + my_ldflags += -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).