CFI include/exclude path support (Soong)
am: 1fa3ac552d
Change-Id: Ie568728de525dad6917ea3d399c49baf1e76165a
This commit is contained in:
commit
fbfc32ea1b
|
@ -656,3 +656,17 @@ func (c *config) IntegerOverflowDisabledForPath(path string) bool {
|
|||
}
|
||||
return prefixInList(path, *c.ProductVariables.IntegerOverflowExcludePaths)
|
||||
}
|
||||
|
||||
func (c *config) CFIDisabledForPath(path string) bool {
|
||||
if c.ProductVariables.CFIExcludePaths == nil {
|
||||
return false
|
||||
}
|
||||
return prefixInList(path, *c.ProductVariables.CFIExcludePaths)
|
||||
}
|
||||
|
||||
func (c *config) CFIEnabledForPath(path string) bool {
|
||||
if c.ProductVariables.CFIIncludePaths == nil {
|
||||
return false
|
||||
}
|
||||
return prefixInList(path, *c.ProductVariables.CFIIncludePaths)
|
||||
}
|
||||
|
|
|
@ -153,7 +153,6 @@ type productVariables struct {
|
|||
UseGoma *bool `json:",omitempty"`
|
||||
Debuggable *bool `json:",omitempty"`
|
||||
Eng *bool `json:",omitempty"`
|
||||
EnableCFI *bool `json:",omitempty"`
|
||||
Device_uses_hwc2 *bool `json:",omitempty"`
|
||||
Treble *bool `json:",omitempty"`
|
||||
Pdk *bool `json:",omitempty"`
|
||||
|
@ -162,6 +161,10 @@ type productVariables struct {
|
|||
|
||||
IntegerOverflowExcludePaths *[]string `json:",omitempty"`
|
||||
|
||||
EnableCFI *bool `json:",omitempty"`
|
||||
CFIExcludePaths *[]string `json:",omitempty"`
|
||||
CFIIncludePaths *[]string `json:",omitempty"`
|
||||
|
||||
VendorPath *string `json:",omitempty"`
|
||||
|
||||
ClangTidy *bool `json:",omitempty"`
|
||||
|
|
|
@ -187,7 +187,9 @@ func (sanitize *sanitize) begin(ctx BaseModuleContext) {
|
|||
}
|
||||
|
||||
if found, globalSanitizers = removeFromList("cfi", globalSanitizers); found && s.Cfi == nil {
|
||||
s.Cfi = boolPtr(true)
|
||||
if !ctx.AConfig().CFIDisabledForPath(ctx.ModuleDir()) {
|
||||
s.Cfi = boolPtr(true)
|
||||
}
|
||||
}
|
||||
|
||||
if found, globalSanitizers = removeFromList("integer_overflow", globalSanitizers); found && s.Integer_overflow == nil {
|
||||
|
@ -205,11 +207,24 @@ func (sanitize *sanitize) begin(ctx BaseModuleContext) {
|
|||
s.Diag.Integer_overflow = boolPtr(true)
|
||||
}
|
||||
|
||||
if found, globalSanitizersDiag = removeFromList("cfi", globalSanitizersDiag); found &&
|
||||
s.Diag.Cfi == nil && Bool(s.Cfi) {
|
||||
s.Diag.Cfi = boolPtr(true)
|
||||
}
|
||||
|
||||
if len(globalSanitizersDiag) > 0 {
|
||||
ctx.ModuleErrorf("unknown global sanitizer diagnostics option %s", globalSanitizersDiag[0])
|
||||
}
|
||||
}
|
||||
|
||||
// Enable CFI for all components in the include paths
|
||||
if s.Cfi == nil && ctx.AConfig().CFIEnabledForPath(ctx.ModuleDir()) {
|
||||
s.Cfi = boolPtr(true)
|
||||
if inList("cfi", ctx.AConfig().SanitizeDeviceDiag()) {
|
||||
s.Diag.Cfi = boolPtr(true)
|
||||
}
|
||||
}
|
||||
|
||||
// CFI needs gold linker, and mips toolchain does not have one.
|
||||
if !ctx.AConfig().EnableCFI() || ctx.Arch().ArchType == android.Mips || ctx.Arch().ArchType == android.Mips64 {
|
||||
s.Cfi = nil
|
||||
|
|
Loading…
Reference in New Issue