diff --git a/android/config.go b/android/config.go index 6d286802f..36034775a 100644 --- a/android/config.go +++ b/android/config.go @@ -398,6 +398,10 @@ func (c *config) SanitizeDeviceArch() []string { return append([]string(nil), c.ProductVariables.SanitizeDeviceArch...) } +func (c *config) EnableCFI() bool { + return Bool(c.ProductVariables.EnableCFI) +} + func (c *config) Android64() bool { for _, t := range c.Targets[Device] { if t.Arch.ArchType.Multilib == "lib64" { diff --git a/android/variable.go b/android/variable.go index 271454a6f..bb84be289 100644 --- a/android/variable.go +++ b/android/variable.go @@ -124,6 +124,7 @@ type productVariables struct { UseGoma *bool `json:",omitempty"` Debuggable *bool `json:",omitempty"` Eng *bool `json:",omitempty"` + EnableCFI *bool `json:",omitempty"` VendorPath *string `json:",omitempty"` diff --git a/cc/sanitize.go b/cc/sanitize.go index 447c5b42c..6ab66997c 100644 --- a/cc/sanitize.go +++ b/cc/sanitize.go @@ -161,6 +161,11 @@ func (sanitize *sanitize) begin(ctx BaseModuleContext) { } } + if !ctx.AConfig().EnableCFI() { + s.Cfi = nil + s.Diag.Cfi = nil + } + if ctx.staticBinary() { s.Address = nil s.Coverage = nil