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

Commit 8566eb0e authored by Evgenii Stepanov's avatar Evgenii Stepanov
Browse files

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 <binary> | grep .note.android.memtag
Bug: 322107634
Change-Id: I4a25509ff280e25d14576157903a2bbf162a4895
parent 7ba1e17d
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -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).