Export CC HWASan sanitizer type
We need this so that HWASan sanitizer mutator in CC can sanitize Rust. Bug: 180495975 Test: m nothing Change-Id: I2c9eb248df4e55a33f5d45083e91588f4c8e3e94
This commit is contained in:
4
cc/cc.go
4
cc/cc.go
@@ -56,8 +56,8 @@ func RegisterCCBuildComponents(ctx android.RegistrationContext) {
|
|||||||
ctx.TopDown("asan_deps", sanitizerDepsMutator(Asan))
|
ctx.TopDown("asan_deps", sanitizerDepsMutator(Asan))
|
||||||
ctx.BottomUp("asan", sanitizerMutator(Asan)).Parallel()
|
ctx.BottomUp("asan", sanitizerMutator(Asan)).Parallel()
|
||||||
|
|
||||||
ctx.TopDown("hwasan_deps", sanitizerDepsMutator(hwasan))
|
ctx.TopDown("hwasan_deps", sanitizerDepsMutator(Hwasan))
|
||||||
ctx.BottomUp("hwasan", sanitizerMutator(hwasan)).Parallel()
|
ctx.BottomUp("hwasan", sanitizerMutator(Hwasan)).Parallel()
|
||||||
|
|
||||||
ctx.TopDown("fuzzer_deps", sanitizerDepsMutator(Fuzzer))
|
ctx.TopDown("fuzzer_deps", sanitizerDepsMutator(Fuzzer))
|
||||||
ctx.BottomUp("fuzzer", sanitizerMutator(Fuzzer)).Parallel()
|
ctx.BottomUp("fuzzer", sanitizerMutator(Fuzzer)).Parallel()
|
||||||
|
@@ -83,7 +83,7 @@ func boolPtr(v bool) *bool {
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
Asan SanitizerType = iota + 1
|
Asan SanitizerType = iota + 1
|
||||||
hwasan
|
Hwasan
|
||||||
tsan
|
tsan
|
||||||
intOverflow
|
intOverflow
|
||||||
cfi
|
cfi
|
||||||
@@ -97,7 +97,7 @@ func (t SanitizerType) variationName() string {
|
|||||||
switch t {
|
switch t {
|
||||||
case Asan:
|
case Asan:
|
||||||
return "asan"
|
return "asan"
|
||||||
case hwasan:
|
case Hwasan:
|
||||||
return "hwasan"
|
return "hwasan"
|
||||||
case tsan:
|
case tsan:
|
||||||
return "tsan"
|
return "tsan"
|
||||||
@@ -121,7 +121,7 @@ func (t SanitizerType) name() string {
|
|||||||
switch t {
|
switch t {
|
||||||
case Asan:
|
case Asan:
|
||||||
return "address"
|
return "address"
|
||||||
case hwasan:
|
case Hwasan:
|
||||||
return "hwaddress"
|
return "hwaddress"
|
||||||
case memtag_heap:
|
case memtag_heap:
|
||||||
return "memtag_heap"
|
return "memtag_heap"
|
||||||
@@ -144,7 +144,7 @@ func (*Module) SanitizerSupported(t SanitizerType) bool {
|
|||||||
switch t {
|
switch t {
|
||||||
case Asan:
|
case Asan:
|
||||||
return true
|
return true
|
||||||
case hwasan:
|
case Hwasan:
|
||||||
return true
|
return true
|
||||||
case tsan:
|
case tsan:
|
||||||
return true
|
return true
|
||||||
@@ -163,7 +163,7 @@ func (*Module) SanitizerSupported(t SanitizerType) bool {
|
|||||||
|
|
||||||
// incompatibleWithCfi returns true if a sanitizer is incompatible with CFI.
|
// incompatibleWithCfi returns true if a sanitizer is incompatible with CFI.
|
||||||
func (t SanitizerType) incompatibleWithCfi() bool {
|
func (t SanitizerType) incompatibleWithCfi() bool {
|
||||||
return t == Asan || t == Fuzzer || t == hwasan
|
return t == Asan || t == Fuzzer || t == Hwasan
|
||||||
}
|
}
|
||||||
|
|
||||||
type SanitizeUserProps struct {
|
type SanitizeUserProps struct {
|
||||||
@@ -745,7 +745,7 @@ func (sanitize *sanitize) getSanitizerBoolPtr(t SanitizerType) *bool {
|
|||||||
switch t {
|
switch t {
|
||||||
case Asan:
|
case Asan:
|
||||||
return sanitize.Properties.Sanitize.Address
|
return sanitize.Properties.Sanitize.Address
|
||||||
case hwasan:
|
case Hwasan:
|
||||||
return sanitize.Properties.Sanitize.Hwaddress
|
return sanitize.Properties.Sanitize.Hwaddress
|
||||||
case tsan:
|
case tsan:
|
||||||
return sanitize.Properties.Sanitize.Thread
|
return sanitize.Properties.Sanitize.Thread
|
||||||
@@ -767,7 +767,7 @@ func (sanitize *sanitize) getSanitizerBoolPtr(t SanitizerType) *bool {
|
|||||||
// isUnsanitizedVariant returns true if no sanitizers are enabled.
|
// isUnsanitizedVariant returns true if no sanitizers are enabled.
|
||||||
func (sanitize *sanitize) isUnsanitizedVariant() bool {
|
func (sanitize *sanitize) isUnsanitizedVariant() bool {
|
||||||
return !sanitize.isSanitizerEnabled(Asan) &&
|
return !sanitize.isSanitizerEnabled(Asan) &&
|
||||||
!sanitize.isSanitizerEnabled(hwasan) &&
|
!sanitize.isSanitizerEnabled(Hwasan) &&
|
||||||
!sanitize.isSanitizerEnabled(tsan) &&
|
!sanitize.isSanitizerEnabled(tsan) &&
|
||||||
!sanitize.isSanitizerEnabled(cfi) &&
|
!sanitize.isSanitizerEnabled(cfi) &&
|
||||||
!sanitize.isSanitizerEnabled(scs) &&
|
!sanitize.isSanitizerEnabled(scs) &&
|
||||||
@@ -778,7 +778,7 @@ func (sanitize *sanitize) isUnsanitizedVariant() bool {
|
|||||||
// isVariantOnProductionDevice returns true if variant is for production devices (no non-production sanitizers enabled).
|
// isVariantOnProductionDevice returns true if variant is for production devices (no non-production sanitizers enabled).
|
||||||
func (sanitize *sanitize) isVariantOnProductionDevice() bool {
|
func (sanitize *sanitize) isVariantOnProductionDevice() bool {
|
||||||
return !sanitize.isSanitizerEnabled(Asan) &&
|
return !sanitize.isSanitizerEnabled(Asan) &&
|
||||||
!sanitize.isSanitizerEnabled(hwasan) &&
|
!sanitize.isSanitizerEnabled(Hwasan) &&
|
||||||
!sanitize.isSanitizerEnabled(tsan) &&
|
!sanitize.isSanitizerEnabled(tsan) &&
|
||||||
!sanitize.isSanitizerEnabled(Fuzzer)
|
!sanitize.isSanitizerEnabled(Fuzzer)
|
||||||
}
|
}
|
||||||
@@ -787,7 +787,7 @@ func (sanitize *sanitize) SetSanitizer(t SanitizerType, b bool) {
|
|||||||
switch t {
|
switch t {
|
||||||
case Asan:
|
case Asan:
|
||||||
sanitize.Properties.Sanitize.Address = boolPtr(b)
|
sanitize.Properties.Sanitize.Address = boolPtr(b)
|
||||||
case hwasan:
|
case Hwasan:
|
||||||
sanitize.Properties.Sanitize.Hwaddress = boolPtr(b)
|
sanitize.Properties.Sanitize.Hwaddress = boolPtr(b)
|
||||||
case tsan:
|
case tsan:
|
||||||
sanitize.Properties.Sanitize.Thread = boolPtr(b)
|
sanitize.Properties.Sanitize.Thread = boolPtr(b)
|
||||||
@@ -902,7 +902,7 @@ func sanitizerDepsMutator(t SanitizerType) func(android.TopDownMutatorContext) {
|
|||||||
if d, ok := child.(PlatformSanitizeable); ok && d.SanitizePropDefined() &&
|
if d, ok := child.(PlatformSanitizeable); ok && d.SanitizePropDefined() &&
|
||||||
!d.SanitizeNever() &&
|
!d.SanitizeNever() &&
|
||||||
!d.IsSanitizerExplicitlyDisabled(t) {
|
!d.IsSanitizerExplicitlyDisabled(t) {
|
||||||
if t == cfi || t == hwasan || t == scs {
|
if t == cfi || t == Hwasan || t == scs {
|
||||||
if d.StaticallyLinked() && d.SanitizerSupported(t) {
|
if d.StaticallyLinked() && d.SanitizerSupported(t) {
|
||||||
// Rust does not support some of these sanitizers, so we need to check if it's
|
// Rust does not support some of these sanitizers, so we need to check if it's
|
||||||
// supported before setting this true.
|
// supported before setting this true.
|
||||||
@@ -1280,7 +1280,7 @@ func sanitizerMutator(t SanitizerType) func(android.BottomUpMutatorContext) {
|
|||||||
// For cfi/scs/hwasan, we can export both sanitized and un-sanitized variants
|
// For cfi/scs/hwasan, we can export both sanitized and un-sanitized variants
|
||||||
// to Make, because the sanitized version has a different suffix in name.
|
// to Make, because the sanitized version has a different suffix in name.
|
||||||
// For other types of sanitizers, suppress the variation that is disabled.
|
// For other types of sanitizers, suppress the variation that is disabled.
|
||||||
if t != cfi && t != scs && t != hwasan {
|
if t != cfi && t != scs && t != Hwasan {
|
||||||
if isSanitizerEnabled {
|
if isSanitizerEnabled {
|
||||||
modules[0].(PlatformSanitizeable).SetPreventInstall()
|
modules[0].(PlatformSanitizeable).SetPreventInstall()
|
||||||
modules[0].(PlatformSanitizeable).SetHideFromMake()
|
modules[0].(PlatformSanitizeable).SetHideFromMake()
|
||||||
@@ -1294,7 +1294,7 @@ func sanitizerMutator(t SanitizerType) func(android.BottomUpMutatorContext) {
|
|||||||
if c.StaticallyLinked() && c.ExportedToMake() {
|
if c.StaticallyLinked() && c.ExportedToMake() {
|
||||||
if t == cfi {
|
if t == cfi {
|
||||||
cfiStaticLibs(mctx.Config()).add(c, c.Module().Name())
|
cfiStaticLibs(mctx.Config()).add(c, c.Module().Name())
|
||||||
} else if t == hwasan {
|
} else if t == Hwasan {
|
||||||
hwasanStaticLibs(mctx.Config()).add(c, c.Module().Name())
|
hwasanStaticLibs(mctx.Config()).add(c, c.Module().Name())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1411,7 +1411,7 @@ var hwasanStaticLibsKey = android.NewOnceKey("hwasanStaticLibs")
|
|||||||
|
|
||||||
func hwasanStaticLibs(config android.Config) *sanitizerStaticLibsMap {
|
func hwasanStaticLibs(config android.Config) *sanitizerStaticLibsMap {
|
||||||
return config.Once(hwasanStaticLibsKey, func() interface{} {
|
return config.Once(hwasanStaticLibsKey, func() interface{} {
|
||||||
return newSanitizerStaticLibsMap(hwasan)
|
return newSanitizerStaticLibsMap(Hwasan)
|
||||||
}).(*sanitizerStaticLibsMap)
|
}).(*sanitizerStaticLibsMap)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -196,7 +196,7 @@ func isSnapshotAware(cfg android.DeviceConfig, m *Module, inProprietaryPath bool
|
|||||||
if m.sanitize != nil {
|
if m.sanitize != nil {
|
||||||
// scs and hwasan export both sanitized and unsanitized variants for static and header
|
// scs and hwasan export both sanitized and unsanitized variants for static and header
|
||||||
// Always use unsanitized variants of them.
|
// Always use unsanitized variants of them.
|
||||||
for _, t := range []SanitizerType{scs, hwasan} {
|
for _, t := range []SanitizerType{scs, Hwasan} {
|
||||||
if !l.shared() && m.sanitize.isSanitizerEnabled(t) {
|
if !l.shared() && m.sanitize.isSanitizerEnabled(t) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user