From f97782b18cc3dae0f0fb4b680e1488b000723396 Mon Sep 17 00:00:00 2001 From: Jiyong Park Date: Wed, 13 Feb 2019 20:28:58 +0900 Subject: [PATCH] Remove prefer_sanitize.* properties The properties are no longer required as an APEX module is mutated with required sanitizers which are gathered by scanning the sanitizers that are enabled for its direct dependencies. Bug: 124128094 Test: m on marlin The extractor libs are found under /system/apex/com.android.media Merged-In: I55961d400dcbac067a5c0dcecb90e399d4991a70 Change-Id: I55961d400dcbac067a5c0dcecb90e399d4991a70 (cherry picked from commit abda0eb76b8aa9aac3220e4f60391210fbcb5b53) --- apex/apex.go | 44 ++++++++++---------------------------------- cc/sanitize.go | 9 +++++++++ 2 files changed, 19 insertions(+), 34 deletions(-) diff --git a/apex/apex.go b/apex/apex.go index 5e1a94344..7633ad201 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -257,18 +257,8 @@ type apexBundleProperties struct { Multilib apexMultilibProperties - Prefer_sanitize struct { - // Prefer native libraries with asan if available - Address *bool - // Prefer native libraries with hwasan if available - Hwaddress *bool - // Prefer native libraries with tsan if available - Thread *bool - // Prefer native libraries with integer_overflow if available - Integer_overflow *bool - // Prefer native libraries with cfi if available - Cfi *bool - } + // List of sanitizer names that this APEX is enabled for + SanitizerNames []string `blueprint:"mutated"` } type apexTargetBundleProperties struct { @@ -551,29 +541,15 @@ func (a *apexBundle) getImageVariation(config android.DeviceConfig) string { } } +func (a *apexBundle) EnableSanitizer(sanitizerName string) { + if !android.InList(sanitizerName, a.properties.SanitizerNames) { + a.properties.SanitizerNames = append(a.properties.SanitizerNames, sanitizerName) + } +} + func (a *apexBundle) IsSanitizerEnabled(ctx android.BaseModuleContext, sanitizerName string) bool { - // If this APEX is configured to prefer a sanitizer, use it - switch sanitizerName { - case "asan": - if proptools.Bool(a.properties.Prefer_sanitize.Address) { - return true - } - case "hwasan": - if proptools.Bool(a.properties.Prefer_sanitize.Hwaddress) { - return true - } - case "tsan": - if proptools.Bool(a.properties.Prefer_sanitize.Thread) { - return true - } - case "cfi": - if proptools.Bool(a.properties.Prefer_sanitize.Cfi) { - return true - } - case "integer_overflow": - if proptools.Bool(a.properties.Prefer_sanitize.Integer_overflow) { - return true - } + if android.InList(sanitizerName, a.properties.SanitizerNames) { + return true } // Then follow the global setting diff --git a/cc/sanitize.go b/cc/sanitize.go index fc2ed5071..729771839 100644 --- a/cc/sanitize.go +++ b/cc/sanitize.go @@ -666,6 +666,14 @@ func sanitizerDepsMutator(t sanitizerType) func(android.TopDownMutatorContext) { } return true }) + } else if sanitizeable, ok := mctx.Module().(Sanitizeable); ok { + // If an APEX module includes a lib which is enabled for a sanitizer T, then + // the APEX module is also enabled for the same sanitizer type. + mctx.VisitDirectDeps(func(child android.Module) { + if c, ok := child.(*Module); ok && c.sanitize.isSanitizerEnabled(t) { + sanitizeable.EnableSanitizer(t.name()) + } + }) } } } @@ -848,6 +856,7 @@ func sanitizerRuntimeMutator(mctx android.BottomUpMutatorContext) { type Sanitizeable interface { android.Module IsSanitizerEnabled(ctx android.BaseModuleContext, sanitizerName string) bool + EnableSanitizer(sanitizerName string) } // Create sanitized variants for modules that need them