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

Commit a2159cd3 authored by Florian Mayer's avatar Florian Mayer Committed by Gerrit Code Review
Browse files

Merge "Revert "[make] Add memtag-stack sanitizer, switch to linker-generated notes.""

parents 739ff268 fe3e5371
Loading
Loading
Loading
Loading
+12 −23
Original line number Diff line number Diff line
@@ -161,11 +161,9 @@ ifeq ($(strip $(ENABLE_CFI)),false)
  my_sanitize_diag := $(filter-out cfi,$(my_sanitize_diag))
endif

# Also disable CFI and MTE if ASAN is enabled.
# Also disable CFI if ASAN is enabled.
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_heap,$(my_sanitize))
  my_sanitize_diag := $(filter-out cfi,$(my_sanitize_diag))
endif

@@ -207,13 +205,10 @@ endif
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))
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_heap,$(my_sanitize))
  my_sanitize := $(filter-out thread,$(my_sanitize))
  my_sanitize := $(filter-out cfi,$(my_sanitize))
endif
@@ -229,27 +224,21 @@ ifneq ($(filter hwaddress,$(my_sanitize)),)
  endif
endif

ifneq ($(filter memtag_heap memtag_stack,$(my_sanitize)),)
ifneq ($(filter memtag_heap,$(my_sanitize)),)
  # Add memtag ELF note.
  ifneq ($(filter EXECUTABLES NATIVE_TESTS,$(LOCAL_MODULE_CLASS)),)
    ifneq ($(filter memtag_heap,$(my_sanitize_diag)),)
    my_cflags += -fsanitize-memtag-mode=sync
    my_sanitize_diag := $(filter-out memtag_heap,$(my_sanitize_diag))
      my_whole_static_libraries += note_memtag_heap_sync
    else
    my_cflags += -fsanitize-memtag-mode=async
      my_whole_static_libraries += note_memtag_heap_async
    endif
  endif

ifneq ($(filter memtag_heap,$(my_sanitize)),)
  my_cflags += -fsanitize=memtag-heap
  # This is all that memtag_heap does - it is not an actual -fsanitize argument.
  # Remove it from the list.
  my_sanitize := $(filter-out memtag_heap,$(my_sanitize))
endif

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
my_sanitize_diag := $(filter-out memtag_heap,$(my_sanitize_diag))

# 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.