Fix -fsanitize=integer not passed for soong builds.
Also filter out -Wl,--no-undefined for all host sanitizers, not just ASan.
UBSan on host defaults to no-trap (i.e. diagnostic mode), and that requires
the runtime library and runs into the same problem with undefined symbols as ASan.
Bug: 34719251
Test: Misc_undefined: ["integer"] on a soong target
Change-Id: I1fb4781f663a11f5f427d50c0bf9beb8e181cd5e
Merged-In: I1fb4781f663a11f5f427d50c0bf9beb8e181cd5e
(cherry picked from commit fe9bc1dccb
)
This commit is contained in:
parent
dadff1b8d2
commit
76cee23144
1 changed files with 5 additions and 5 deletions
|
@ -212,8 +212,8 @@ func (sanitize *sanitize) begin(ctx BaseModuleContext) {
|
||||||
// TODO(ccross): error for compile_multilib = "32"?
|
// TODO(ccross): error for compile_multilib = "32"?
|
||||||
}
|
}
|
||||||
|
|
||||||
if Bool(s.All_undefined) || Bool(s.Undefined) || Bool(s.Address) ||
|
if ctx.Os() != android.Windows && (Bool(s.All_undefined) || Bool(s.Undefined) || Bool(s.Address) || Bool(s.Thread) ||
|
||||||
Bool(s.Thread) || Bool(s.Coverage) || Bool(s.Safestack) || Bool(s.Cfi) {
|
Bool(s.Coverage) || Bool(s.Safestack) || Bool(s.Cfi) || len(s.Misc_undefined) > 0) {
|
||||||
sanitize.Properties.SanitizerEnabled = true
|
sanitize.Properties.SanitizerEnabled = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -308,9 +308,6 @@ func (sanitize *sanitize) flags(ctx ModuleContext, flags Flags) Flags {
|
||||||
// libraries needed with -fsanitize=address. http://b/18650275 (WAI)
|
// libraries needed with -fsanitize=address. http://b/18650275 (WAI)
|
||||||
flags.LdFlags = append(flags.LdFlags, "-lm", "-lpthread")
|
flags.LdFlags = append(flags.LdFlags, "-lm", "-lpthread")
|
||||||
flags.LdFlags = append(flags.LdFlags, "-Wl,--no-as-needed")
|
flags.LdFlags = append(flags.LdFlags, "-Wl,--no-as-needed")
|
||||||
// Host ASAN only links symbols in the final executable, so
|
|
||||||
// there will always be undefined symbols in intermediate libraries.
|
|
||||||
_, flags.LdFlags = removeFromList("-Wl,--no-undefined", flags.LdFlags)
|
|
||||||
} else {
|
} else {
|
||||||
flags.CFlags = append(flags.CFlags, "-mllvm", "-asan-globals=0")
|
flags.CFlags = append(flags.CFlags, "-mllvm", "-asan-globals=0")
|
||||||
flags.DynamicLinker = "/system/bin/linker_asan"
|
flags.DynamicLinker = "/system/bin/linker_asan"
|
||||||
|
@ -355,6 +352,9 @@ func (sanitize *sanitize) flags(ctx ModuleContext, flags Flags) Flags {
|
||||||
flags.CFlags = append(flags.CFlags, "-fno-sanitize-recover=all")
|
flags.CFlags = append(flags.CFlags, "-fno-sanitize-recover=all")
|
||||||
flags.LdFlags = append(flags.LdFlags, sanitizeArg)
|
flags.LdFlags = append(flags.LdFlags, sanitizeArg)
|
||||||
flags.LdFlags = append(flags.LdFlags, "-lrt", "-ldl")
|
flags.LdFlags = append(flags.LdFlags, "-lrt", "-ldl")
|
||||||
|
// Host sanitizers only link symbols in the final executable, so
|
||||||
|
// there will always be undefined symbols in intermediate libraries.
|
||||||
|
_, flags.LdFlags = removeFromList("-Wl,--no-undefined", flags.LdFlags)
|
||||||
} else {
|
} else {
|
||||||
flags.CFlags = append(flags.CFlags, "-fsanitize-trap=all", "-ftrap-function=abort")
|
flags.CFlags = append(flags.CFlags, "-fsanitize-trap=all", "-ftrap-function=abort")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue