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
diff --git a/cc/sanitize.go b/cc/sanitize.go
index 168e6c8..dfd86f0 100644
--- a/cc/sanitize.go
+++ b/cc/sanitize.go
@@ -85,8 +85,9 @@
// 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 @@
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.