From 651275ba90215bcca6d5fb3ca26d05a4de9f1877 Mon Sep 17 00:00:00 2001 From: Ivan Lozano Date: Tue, 13 Jun 2017 10:24:34 -0700 Subject: [PATCH] Add support for misc_undefined diagnostics Setting Sanitize.Diag.Undefined to true does not enable diagnostics for all possible UBSan sanitizers that might be declared in Sanitize.Misc_undefined (specifically unsigned-integer-overflow and nullability-*). This adds an equivalent Sanitize.Diag.Misc_undefined string array to allow diagnostics to be enabled in these sanitizers. Bug: 62546512 Test: make works and device boots. Test: Tested an Android.bp generated binary with the new field enabling unsigned-integer-overflow diagnostics. Change-Id: I9aa7cb2555ab4f94ae1aa290715a617718d936ff --- cc/sanitize.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cc/sanitize.go b/cc/sanitize.go index 168e6c89e..dfd86f08b 100644 --- a/cc/sanitize.go +++ b/cc/sanitize.go @@ -85,8 +85,9 @@ type SanitizeProperties struct { // Replaces abort() on error with a human-readable error message. // Address and Thread sanitizers always run in diagnostic mode. Diag struct { - Undefined *bool `android:"arch_variant"` - Cfi *bool `android:"arch_variant"` + Undefined *bool `android:"arch_variant"` + Cfi *bool `android:"arch_variant"` + Misc_undefined []string `android:"arch_variant"` } // value to pass to -fsanitize-recover= @@ -287,13 +288,12 @@ func (sanitize *sanitize) flags(ctx ModuleContext, flags Flags) Flags { sanitizers = append(sanitizers, sanitize.Properties.Sanitize.Misc_undefined...) } - if Bool(sanitize.Properties.Sanitize.Diag.Undefined) && - (Bool(sanitize.Properties.Sanitize.All_undefined) || - Bool(sanitize.Properties.Sanitize.Undefined) || - len(sanitize.Properties.Sanitize.Misc_undefined) > 0) { + if Bool(sanitize.Properties.Sanitize.Diag.Undefined) { diagSanitizers = append(diagSanitizers, "undefined") } + diagSanitizers = append(diagSanitizers, sanitize.Properties.Sanitize.Diag.Misc_undefined...) + if Bool(sanitize.Properties.Sanitize.Address) { if ctx.Arch().ArchType == android.Arm { // Frame pointer based unwinder in ASan requires ARM frame setup.