Merge "Blacklist code for CFI." am: 367a7da041

am: ddfd8d5ac1

Change-Id: I4ca7ba81aa127f6be2cf8fbc5cf2676346fc1752
This commit is contained in:
Vishwath Mohan 2017-02-15 23:37:52 +00:00 committed by android-build-merger
commit da115e3077
2 changed files with 11 additions and 6 deletions

View File

@ -64,6 +64,9 @@ func makeVarsProvider(ctx android.MakeVarsContext) {
ctx.Strict("ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS", asanLdflags)
ctx.Strict("ADDRESS_SANITIZER_CONFIG_EXTRA_STATIC_LIBRARIES", asanLibs)
ctx.Strict("CFI_EXTRA_CFLAGS", cfiCflags)
ctx.Strict("CFI_EXTRA_LDFLAGS", cfiLdflags)
ctx.Strict("DEFAULT_C_STD_VERSION", config.CStdVersion)
ctx.Strict("DEFAULT_CPP_STD_VERSION", config.CppStdVersion)
ctx.Strict("DEFAULT_GCC_CPP_STD_VERSION", config.GccCppStdVersion)

View File

@ -28,6 +28,12 @@ const (
asanCflags = "-fno-omit-frame-pointer"
asanLdflags = "-Wl,-u,__asan_preinit"
asanLibs = "libasan"
cfiCflags = "-flto -fsanitize-cfi-cross-dso -fvisibility=default " +
"-fsanitize-blacklist=external/compiler-rt/lib/cfi/cfi_blacklist.txt"
// FIXME: revert the __cfi_check flag when clang is updated to r280031.
cfiLdflags = "-flto -fsanitize-cfi-cross-dso -fsanitize=cfi " +
"-Wl,-plugin-opt,O1 -Wl,-export-dynamic-symbol=__cfi_check"
)
type sanitizerType int
@ -324,12 +330,8 @@ func (sanitize *sanitize) flags(ctx ModuleContext, flags Flags) Flags {
flags.LdFlags = append(flags.LdFlags, "-march=armv7-a")
}
sanitizers = append(sanitizers, "cfi")
cfiFlags := []string{"-flto", "-fsanitize=cfi", "-fsanitize-cfi-cross-dso"}
flags.CFlags = append(flags.CFlags, cfiFlags...)
flags.CFlags = append(flags.CFlags, "-fvisibility=default")
flags.LdFlags = append(flags.LdFlags, cfiFlags...)
// FIXME: revert the __cfi_check flag when clang is updated to r280031.
flags.LdFlags = append(flags.LdFlags, "-Wl,-plugin-opt,O1", "-Wl,-export-dynamic-symbol=__cfi_check")
flags.CFlags = append(flags.CFlags, cfiCflags)
flags.LdFlags = append(flags.LdFlags, cfiLdflags)
if Bool(sanitize.Properties.Sanitize.Diag.Cfi) {
diagSanitizers = append(diagSanitizers, "cfi")
}