diff options
author | Evgenii Stepanov <eugenis@google.com> | 2016-05-12 21:59:25 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2016-05-12 21:59:25 +0000 |
commit | 2522660da7fa8039176842e5e353a57e7f1d7772 (patch) | |
tree | c1887bebf076e75aa1e2a8c3c156627736d1c564 | |
parent | 0414479ba4f26598a5557d2334b9f5ec58c772f8 (diff) | |
parent | 0a8a0d09d1f041a155c8090f632b1236f8ab1c0e (diff) | |
download | build_soong-2522660da7fa8039176842e5e353a57e7f1d7772.tar.gz build_soong-2522660da7fa8039176842e5e353a57e7f1d7772.tar.bz2 build_soong-2522660da7fa8039176842e5e353a57e7f1d7772.zip |
Merge "Support SANITIZE_TARGET=safe-stack in soong."
-rw-r--r-- | cc/sanitize.go | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/cc/sanitize.go b/cc/sanitize.go index 670443bf..94c56ce6 100644 --- a/cc/sanitize.go +++ b/cc/sanitize.go @@ -59,6 +59,7 @@ type SanitizeProperties struct { All_undefined bool `android:"arch_variant"` Misc_undefined []string `android:"arch_variant"` Coverage bool `android:"arch_variant"` + SafeStack bool `android:"arch_variant"` // value to pass to -fsantitize-recover= Recover []string @@ -127,15 +128,20 @@ func (sanitize *sanitize) begin(ctx BaseModuleContext) { sanitize.Properties.Sanitize.Coverage = true } + if found, globalSanitizers = removeFromList("safe-stack", globalSanitizers); found { + sanitize.Properties.Sanitize.SafeStack = true + } + if len(globalSanitizers) > 0 { ctx.ModuleErrorf("unknown global sanitizer option %s", globalSanitizers[0]) } sanitize.Properties.SanitizerEnabled = true } - if !ctx.toolchain().Is64Bit() && sanitize.Properties.Sanitize.Thread { - // TSAN is not supported on 32-bit architectures + if !ctx.toolchain().Is64Bit() { + // TSAN and SafeStack are not supported on 32-bit architectures sanitize.Properties.Sanitize.Thread = false + sanitize.Properties.Sanitize.SafeStack = false // TODO(ccross): error for compile_multilib = "32"? } @@ -239,6 +245,10 @@ func (sanitize *sanitize) flags(ctx ModuleContext, flags Flags) Flags { flags.CFlags = append(flags.CFlags, "-fsanitize-coverage=edge,indirect-calls,8bit-counters,trace-cmp") } + if sanitize.Properties.Sanitize.SafeStack { + sanitizers = append(sanitizers, "safe-stack") + } + if sanitize.Properties.Sanitize.Recover != nil { flags.CFlags = append(flags.CFlags, "-fsanitize-recover="+ strings.Join(sanitize.Properties.Sanitize.Recover, ",")) |