From ad73b2e18a8baddef74f69ded8efa4fc502a626d Mon Sep 17 00:00:00 2001 From: Kostya Kortchinsky Date: Thu, 11 Oct 2018 08:38:39 -0700 Subject: [PATCH] Scudo minimal runtime support for Soong Scudo is now compatible with the -fsanitize-minimal-runtime, and offers a new dynamic library that doesn't bundle UBSan. This patch adds support for this new library in Soong, preferring it over the full one, unless a UBSan or diagnostic dependency is found. Test: aosp compiled with m -j Test: local test enabling Scudo for tombstoned Change-Id: I17794131db148b33f8a8710ac43302cadf1af314 --- cc/config/toolchain.go | 4 ++++ cc/makevars.go | 1 + cc/sanitize.go | 7 +++++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/cc/config/toolchain.go b/cc/config/toolchain.go index 997bca6b9..d5e9d0169 100644 --- a/cc/config/toolchain.go +++ b/cc/config/toolchain.go @@ -220,6 +220,10 @@ func ScudoRuntimeLibrary(t Toolchain) string { return LibclangRuntimeLibrary(t, "scudo") } +func ScudoMinimalRuntimeLibrary(t Toolchain) string { + return LibclangRuntimeLibrary(t, "scudo_minimal") +} + func ToolPath(t Toolchain) string { if p := t.ToolPath(); p != "" { return p diff --git a/cc/makevars.go b/cc/makevars.go index 47e549189..993b2a8ba 100644 --- a/cc/makevars.go +++ b/cc/makevars.go @@ -281,6 +281,7 @@ func makeVarsToolchain(ctx android.MakeVarsContext, secondPrefix string, ctx.Strict(secondPrefix+"UBSAN_MINIMAL_RUNTIME_LIBRARY", strings.TrimSuffix(config.UndefinedBehaviorSanitizerMinimalRuntimeLibrary(toolchain), ".a")) ctx.Strict(secondPrefix+"TSAN_RUNTIME_LIBRARY", strings.TrimSuffix(config.ThreadSanitizerRuntimeLibrary(toolchain), ".so")) ctx.Strict(secondPrefix+"SCUDO_RUNTIME_LIBRARY", strings.TrimSuffix(config.ScudoRuntimeLibrary(toolchain), ".so")) + ctx.Strict(secondPrefix+"SCUDO_MINIMAL_RUNTIME_LIBRARY", strings.TrimSuffix(config.ScudoMinimalRuntimeLibrary(toolchain), ".so")) } // This is used by external/gentoo/... diff --git a/cc/sanitize.go b/cc/sanitize.go index 8262a6810..3fef6a8d0 100644 --- a/cc/sanitize.go +++ b/cc/sanitize.go @@ -531,7 +531,11 @@ func (sanitize *sanitize) flags(ctx ModuleContext, flags Flags) Flags { } else if Bool(sanitize.Properties.Sanitize.Thread) { runtimeLibrary = config.ThreadSanitizerRuntimeLibrary(ctx.toolchain()) } else if Bool(sanitize.Properties.Sanitize.Scudo) { - runtimeLibrary = config.ScudoRuntimeLibrary(ctx.toolchain()) + if len(diagSanitizers) == 0 && !sanitize.Properties.UbsanRuntimeDep { + runtimeLibrary = config.ScudoMinimalRuntimeLibrary(ctx.toolchain()) + } else { + runtimeLibrary = config.ScudoRuntimeLibrary(ctx.toolchain()) + } } else if len(diagSanitizers) > 0 || sanitize.Properties.UbsanRuntimeDep { runtimeLibrary = config.UndefinedBehaviorSanitizerRuntimeLibrary(ctx.toolchain()) } @@ -831,7 +835,6 @@ func hwasanVendorStaticLibs(config android.Config) *[]string { func enableMinimalRuntime(sanitize *sanitize) bool { if !Bool(sanitize.Properties.Sanitize.Address) && !Bool(sanitize.Properties.Sanitize.Hwaddress) && - !Bool(sanitize.Properties.Sanitize.Scudo) && (Bool(sanitize.Properties.Sanitize.Integer_overflow) || len(sanitize.Properties.Sanitize.Misc_undefined) > 0) && !(Bool(sanitize.Properties.Sanitize.Diag.Integer_overflow) ||