diff options
| author | 2018-02-07 03:14:20 +0000 | |
|---|---|---|
| committer | 2018-02-07 03:14:20 +0000 | |
| commit | 966bdded1f34ddd192c879ef355e4d6904fbc1ed (patch) | |
| tree | 39a20380bd3e0ae7a4ee364144a583eab66b6b43 | |
| parent | ca59511e215dfd709e54315e09e9c9fb1de75b81 (diff) | |
| parent | 3ed1f70414d71819eaafed49fe4237527b0ef824 (diff) | |
Merge "Enable emutls with -flto for Android sanitize=cfi"
| -rw-r--r-- | cc/lto.go | 3 | ||||
| -rw-r--r-- | cc/sanitize.go | 6 |
2 files changed, 8 insertions, 1 deletions
@@ -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}") diff --git a/cc/sanitize.go b/cc/sanitize.go index 02aedc890..ac6cb778a 100644 --- a/cc/sanitize.go +++ b/cc/sanitize.go @@ -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") |