Merge "Pass HWASan workarounds cflags to linker as well" am: 51ade343eb
am: 53f0f3e683
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1880991 Change-Id: I7b99de748c4d427e561a582cf2f2eb94dcc66101
This commit is contained in:
@@ -39,8 +39,15 @@ var (
|
|||||||
}
|
}
|
||||||
asanLdflags = []string{"-Wl,-u,__asan_preinit"}
|
asanLdflags = []string{"-Wl,-u,__asan_preinit"}
|
||||||
|
|
||||||
hwasanCflags = []string{"-fno-omit-frame-pointer", "-Wno-frame-larger-than=",
|
hwasanCflags = []string{
|
||||||
|
"-fno-omit-frame-pointer",
|
||||||
|
"-Wno-frame-larger-than=",
|
||||||
"-fsanitize-hwaddress-abi=platform",
|
"-fsanitize-hwaddress-abi=platform",
|
||||||
|
}
|
||||||
|
|
||||||
|
// ThinLTO performs codegen during link time, thus these flags need to
|
||||||
|
// passed to both CFLAGS and LDFLAGS.
|
||||||
|
hwasanCommonflags = []string{
|
||||||
// The following improves debug location information
|
// The following improves debug location information
|
||||||
// availability at the cost of its accuracy. It increases
|
// availability at the cost of its accuracy. It increases
|
||||||
// the likelihood of a stack variable's frame offset
|
// the likelihood of a stack variable's frame offset
|
||||||
@@ -48,11 +55,11 @@ var (
|
|||||||
// for the quality of hwasan reports. The downside is a
|
// for the quality of hwasan reports. The downside is a
|
||||||
// higher number of "optimized out" stack variables.
|
// higher number of "optimized out" stack variables.
|
||||||
// b/112437883.
|
// b/112437883.
|
||||||
"-mllvm", "-instcombine-lower-dbg-declare=0",
|
"-instcombine-lower-dbg-declare=0",
|
||||||
// TODO(b/159343917): HWASan and GlobalISel don't play nicely, and
|
// TODO(b/159343917): HWASan and GlobalISel don't play nicely, and
|
||||||
// GlobalISel is the default at -O0 on aarch64.
|
// GlobalISel is the default at -O0 on aarch64.
|
||||||
"-mllvm", "--aarch64-enable-global-isel-at-O=-1",
|
"--aarch64-enable-global-isel-at-O=-1",
|
||||||
"-mllvm", "-fast-isel=false",
|
"-fast-isel=false",
|
||||||
}
|
}
|
||||||
|
|
||||||
cfiCflags = []string{"-flto", "-fsanitize-cfi-cross-dso",
|
cfiCflags = []string{"-flto", "-fsanitize-cfi-cross-dso",
|
||||||
@@ -629,6 +636,14 @@ func (sanitize *sanitize) flags(ctx ModuleContext, flags Flags) Flags {
|
|||||||
|
|
||||||
if Bool(sanitize.Properties.Sanitize.Hwaddress) {
|
if Bool(sanitize.Properties.Sanitize.Hwaddress) {
|
||||||
flags.Local.CFlags = append(flags.Local.CFlags, hwasanCflags...)
|
flags.Local.CFlags = append(flags.Local.CFlags, hwasanCflags...)
|
||||||
|
|
||||||
|
for _, flag := range hwasanCommonflags {
|
||||||
|
flags.Local.CFlags = append(flags.Local.CFlags, "-mllvm", flag)
|
||||||
|
}
|
||||||
|
for _, flag := range hwasanCommonflags {
|
||||||
|
flags.Local.LdFlags = append(flags.Local.LdFlags, "-Wl,-mllvm,"+flag)
|
||||||
|
}
|
||||||
|
|
||||||
if Bool(sanitize.Properties.Sanitize.Writeonly) {
|
if Bool(sanitize.Properties.Sanitize.Writeonly) {
|
||||||
flags.Local.CFlags = append(flags.Local.CFlags, "-mllvm", "-hwasan-instrument-reads=0")
|
flags.Local.CFlags = append(flags.Local.CFlags, "-mllvm", "-hwasan-instrument-reads=0")
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user