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: I189ffd42760f0ea8d151717337b9355b37cb207b
diff --git a/cc/sanitize.go b/cc/sanitize.go
index b795cc3..b98797a 100644
--- a/cc/sanitize.go
+++ b/cc/sanitize.go
@@ -167,7 +167,8 @@
}
}
- if !ctx.AConfig().EnableCFI() {
+ // CFI needs gold linker, and mips toolchain does not have one.
+ if !ctx.AConfig().EnableCFI() || ctx.Arch().ArchType == android.Mips || ctx.Arch().ArchType == android.Mips64 {
s.Cfi = nil
s.Diag.Cfi = nil
}
@@ -312,6 +313,9 @@
// __cfi_check needs to be built as Thumb (see the code in linker_cfi.cpp). LLVM is not set up
// to do this on a function basis, so force Thumb on the entire module.
flags.RequiredInstructionSet = "thumb"
+ // Workaround for b/33678192. CFI jumptables need Thumb2 codegen. Revert when
+ // Clang is updated past r290384.
+ flags.LdFlags = append(flags.LdFlags, "-march=armv7-a")
}
sanitizers = append(sanitizers, "cfi")
cfiFlags := []string{"-flto", "-fsanitize=cfi", "-fsanitize-cfi-cross-dso"}