Merge "Enable emutls with -flto for Android sanitize=cfi" am: 966bdded1f

am: 9787126b17

Change-Id: Ie664bbdd74cc299680b17a8436711be1ce3ddbf0
This commit is contained in:
Ryan Prichard 2018-02-07 04:19:47 +00:00 committed by android-build-merger
commit 0beba440a3
2 changed files with 8 additions and 1 deletions

View file

@ -82,7 +82,8 @@ func (lto *lto) flags(ctx BaseModuleContext, flags Flags) Flags {
flags.LdFlags = append(flags.LdFlags, ltoFlag)
if ctx.Device() {
// Work around bug in Clang that doesn't pass correct emulated
// TLS option to target
// TLS option to target. See b/72706604 or
// https://github.com/android-ndk/ndk/issues/498.
flags.LdFlags = append(flags.LdFlags, "-Wl,-plugin-opt,-emulated-tls")
}
flags.ArFlags = append(flags.ArFlags, " --plugin ${config.LLVMGoldPlugin}")

View file

@ -401,6 +401,12 @@ func (sanitize *sanitize) flags(ctx ModuleContext, flags Flags) Flags {
flags.CFlags = append(flags.CFlags, "-fvisibility=default")
}
flags.LdFlags = append(flags.LdFlags, cfiLdflags...)
if ctx.Device() {
// Work around a bug in Clang. The CFI sanitizer requires LTO, and when
// LTO is enabled, the Clang driver fails to enable emutls for Android.
// See b/72706604 or https://github.com/android-ndk/ndk/issues/498.
flags.LdFlags = append(flags.LdFlags, "-Wl,-plugin-opt,-emulated-tls")
}
flags.ArFlags = append(flags.ArFlags, cfiArflags...)
if Bool(sanitize.Properties.Sanitize.Diag.Cfi) {
diagSanitizers = append(diagSanitizers, "cfi")