Merge "Make java_fuzz_host not implement Sanitizeable."

This commit is contained in:
Lukács T. Berki
2022-05-18 06:43:42 +00:00
committed by Gerrit Code Review
2 changed files with 16 additions and 39 deletions

View File

@@ -968,10 +968,9 @@ func sanitizerDepsMutator(t SanitizerType) func(android.TopDownMutatorContext) {
return true return true
}) })
} }
} else if sanitizeable, ok := mctx.Module().(Sanitizeable); ok { } else if jniSanitizeable, ok := mctx.Module().(JniSanitizeable); ok {
// If it's a Java module with native dependencies through jni, // If it's a Java module with native dependencies through jni,
// set the sanitizer for them // set the sanitizer for them
if jniSanitizeable, ok := mctx.Module().(JniSanitizeable); ok {
if jniSanitizeable.IsSanitizerEnabledForJni(mctx, t.name()) { if jniSanitizeable.IsSanitizerEnabledForJni(mctx, t.name()) {
mctx.VisitDirectDeps(func(child android.Module) { mctx.VisitDirectDeps(func(child android.Module) {
if c, ok := child.(PlatformSanitizeable); ok && if c, ok := child.(PlatformSanitizeable); ok &&
@@ -983,8 +982,7 @@ func sanitizerDepsMutator(t SanitizerType) func(android.TopDownMutatorContext) {
} }
}) })
} }
} } else if sanitizeable, ok := mctx.Module().(Sanitizeable); ok {
// If an APEX module includes a lib which is enabled for a sanitizer T, then // 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. // the APEX module is also enabled for the same sanitizer type.
mctx.VisitDirectDeps(func(child android.Module) { mctx.VisitDirectDeps(func(child android.Module) {
@@ -1529,12 +1527,10 @@ func enableMinimalRuntime(sanitize *sanitize) bool {
if !Bool(sanitize.Properties.Sanitize.Address) && if !Bool(sanitize.Properties.Sanitize.Address) &&
!Bool(sanitize.Properties.Sanitize.Hwaddress) && !Bool(sanitize.Properties.Sanitize.Hwaddress) &&
!Bool(sanitize.Properties.Sanitize.Fuzzer) && !Bool(sanitize.Properties.Sanitize.Fuzzer) &&
(Bool(sanitize.Properties.Sanitize.Integer_overflow) || (Bool(sanitize.Properties.Sanitize.Integer_overflow) ||
len(sanitize.Properties.Sanitize.Misc_undefined) > 0 || len(sanitize.Properties.Sanitize.Misc_undefined) > 0 ||
Bool(sanitize.Properties.Sanitize.Undefined) || Bool(sanitize.Properties.Sanitize.Undefined) ||
Bool(sanitize.Properties.Sanitize.All_undefined)) && Bool(sanitize.Properties.Sanitize.All_undefined)) &&
!(Bool(sanitize.Properties.Sanitize.Diag.Integer_overflow) || !(Bool(sanitize.Properties.Sanitize.Diag.Integer_overflow) ||
Bool(sanitize.Properties.Sanitize.Diag.Cfi) || Bool(sanitize.Properties.Sanitize.Diag.Cfi) ||
Bool(sanitize.Properties.Sanitize.Diag.Undefined) || Bool(sanitize.Properties.Sanitize.Diag.Undefined) ||

View File

@@ -50,9 +50,10 @@ type JavaFuzzLibrary struct {
jniFilePaths android.Paths jniFilePaths android.Paths
} }
// IsSanitizerEnabled implemented to make JavaFuzzLibrary implement // IsSanitizerEnabledForJni implemented to make JavaFuzzLibrary implement
// cc.Sanitizeable // cc.JniSanitizeable. It returns a bool for whether a cc dependency should be
func (j *JavaFuzzLibrary) IsSanitizerEnabled(ctx android.BaseModuleContext, sanitizerName string) bool { // sanitized for the given sanitizer or not.
func (j *JavaFuzzLibrary) IsSanitizerEnabledForJni(ctx android.BaseModuleContext, sanitizerName string) bool {
for _, s := range j.jniProperties.Sanitizers { for _, s := range j.jniProperties.Sanitizers {
if sanitizerName == s { if sanitizerName == s {
return true return true
@@ -61,26 +62,6 @@ func (j *JavaFuzzLibrary) IsSanitizerEnabled(ctx android.BaseModuleContext, sani
return false return false
} }
// IsSanitizerEnabledForJni implemented to make JavaFuzzLibrary implement
// cc.JniSanitizeable. It returns a bool for whether a cc dependency should be
// sanitized for the given sanitizer or not.
func (j *JavaFuzzLibrary) IsSanitizerEnabledForJni(ctx android.BaseModuleContext, sanitizerName string) bool {
return j.IsSanitizerEnabled(ctx, sanitizerName)
}
// EnableSanitizer implemented to make JavaFuzzLibrary implement
// cc.Sanitizeable
func (j *JavaFuzzLibrary) EnableSanitizer(sanitizerName string) {
}
// AddSanitizerDependencies implemented to make JavaFuzzLibrary implement
// cc.Sanitizeable
func (j *JavaFuzzLibrary) AddSanitizerDependencies(mctx android.BottomUpMutatorContext, sanitizerName string) {
}
// To verify that JavaFuzzLibrary implements cc.Sanitizeable
var _ cc.Sanitizeable = (*JavaFuzzLibrary)(nil)
func (j *JavaFuzzLibrary) DepsMutator(mctx android.BottomUpMutatorContext) { func (j *JavaFuzzLibrary) DepsMutator(mctx android.BottomUpMutatorContext) {
if len(j.jniProperties.Jni_libs) > 0 { if len(j.jniProperties.Jni_libs) > 0 {
if j.fuzzPackagedModule.FuzzProperties.Fuzz_config == nil { if j.fuzzPackagedModule.FuzzProperties.Fuzz_config == nil {