mirror of
https://github.com/Divested-Mobile/DivestOS-Build.git
synced 2024-12-21 05:44:30 -05:00
57 lines
1.6 KiB
Diff
57 lines
1.6 KiB
Diff
From 2b6950b03eb3d8cc82fa2b0a91db480dacf58a78 Mon Sep 17 00:00:00 2001
|
|
From: Daniel Micay <danielmicay@gmail.com>
|
|
Date: Wed, 23 Aug 2017 20:28:03 -0400
|
|
Subject: [PATCH] use -fwrapv when signed overflow checking is off
|
|
|
|
---
|
|
cc/cc.go | 2 ++
|
|
cc/sanitize.go | 12 ++++++++++++
|
|
2 files changed, 14 insertions(+)
|
|
|
|
diff --git a/cc/cc.go b/cc/cc.go
|
|
index 983ffc0..45a50cf 100644
|
|
--- a/cc/cc.go
|
|
+++ b/cc/cc.go
|
|
@@ -533,6 +533,8 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
|
|
}
|
|
if c.sanitize != nil {
|
|
flags = c.sanitize.flags(ctx, flags)
|
|
+ } else {
|
|
+ flags.CFlags = append(flags.CFlags, "-fwrapv")
|
|
}
|
|
if c.coverage != nil {
|
|
flags = c.coverage.flags(ctx, flags)
|
|
diff --git a/cc/sanitize.go b/cc/sanitize.go
|
|
index 9c3b8e5..1dbd9fe 100644
|
|
--- a/cc/sanitize.go
|
|
+++ b/cc/sanitize.go
|
|
@@ -271,6 +271,7 @@ func (sanitize *sanitize) deps(ctx BaseModuleContext, deps Deps) Deps {
|
|
|
|
func (sanitize *sanitize) flags(ctx ModuleContext, flags Flags) Flags {
|
|
if !sanitize.Properties.SanitizerEnabled {
|
|
+ flags.CFlags = append(flags.CFlags, "-fwrapv")
|
|
return flags
|
|
}
|
|
|
|
@@ -315,6 +316,17 @@ func (sanitize *sanitize) flags(ctx ModuleContext, flags Flags) Flags {
|
|
sanitizers = append(sanitizers, sanitize.Properties.Sanitize.Misc_undefined...)
|
|
}
|
|
|
|
+ wrapv := true
|
|
+ for _, element := range sanitizers {
|
|
+ if (element == "signed-integer-overflow" || element == "integer" || element == "undefined") {
|
|
+ wrapv = false
|
|
+ break
|
|
+ }
|
|
+ }
|
|
+ if wrapv {
|
|
+ flags.CFlags = append(flags.CFlags, "-fwrapv")
|
|
+ }
|
|
+
|
|
if Bool(sanitize.Properties.Sanitize.Diag.Undefined) {
|
|
diagSanitizers = append(diagSanitizers, "undefined")
|
|
}
|
|
--
|
|
2.31.1
|
|
|