Disable CFI on Mips and add -march to linkflags on ARM.
Mips toolchain does not have ld.gold.
ARM change is a workaround for LLVM r290384.
Bug: 33678192
Test: make ENABLE_CFI=1
Change-Id: I77a127e0b472d5da10bf45a2983527a714339cb8
diff --git a/core/config_sanitizers.mk b/core/config_sanitizers.mk
index 38cf86d..5eaf7b1 100644
--- a/core/config_sanitizers.mk
+++ b/core/config_sanitizers.mk
@@ -68,6 +68,12 @@
my_sanitize_diag := $(filter-out cfi,$(my_sanitize_diag))
endif
+# CFI needs gold linker, and mips toolchain does not have one.
+ifneq ($(filter mips mips64,$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)),)
+ my_sanitize := $(filter-out cfi,$(my_sanitize))
+ my_sanitize_diag := $(filter-out cfi,$(my_sanitize_diag))
+endif
+
my_nosanitize = $(strip $(LOCAL_NOSANITIZE))
ifneq ($(my_nosanitize),)
my_sanitize := $(filter-out $(my_nosanitize),$(my_sanitize))
@@ -150,6 +156,11 @@
my_cflags += -flto -fsanitize-cfi-cross-dso -fvisibility=default
my_ldflags += -flto -fsanitize-cfi-cross-dso -fsanitize=cfi -Wl,-plugin-opt,O1 -Wl,-export-dynamic-symbol=__cfi_check
my_arflags += --plugin $(LLVM_PREBUILTS_PATH)/../lib64/LLVMgold.so
+ # Workaround for b/33678192. CFI jumptables need Thumb2 codegen. Revert when
+ # Clang is updated past r290384.
+ ifneq ($(filter arm,$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)),)
+ my_ldflags += -march=armv7-a
+ endif
endif
# If local or global modules need ASAN, add linker flags.