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:
parent
49ab1d38de
commit
6eafc36e60
4
cc/cc.go
4
cc/cc.go
|
@ -56,8 +56,8 @@ func RegisterCCBuildComponents(ctx android.RegistrationContext) {
|
|||
ctx.TopDown("asan_deps", sanitizerDepsMutator(Asan))
|
||||
ctx.BottomUp("asan", sanitizerMutator(Asan)).Parallel()
|
||||
|
||||
ctx.TopDown("hwasan_deps", sanitizerDepsMutator(hwasan))
|
||||
ctx.BottomUp("hwasan", sanitizerMutator(hwasan)).Parallel()
|
||||
ctx.TopDown("hwasan_deps", sanitizerDepsMutator(Hwasan))
|
||||
ctx.BottomUp("hwasan", sanitizerMutator(Hwasan)).Parallel()
|
||||
|
||||
ctx.TopDown("fuzzer_deps", sanitizerDepsMutator(Fuzzer))
|
||||
ctx.BottomUp("fuzzer", sanitizerMutator(Fuzzer)).Parallel()
|
||||
|
|
|
@ -83,7 +83,7 @@ func boolPtr(v bool) *bool {
|
|||
|
||||
const (
|
||||
Asan SanitizerType = iota + 1
|
||||
hwasan
|
||||
Hwasan
|
||||
tsan
|
||||
intOverflow
|
||||
cfi
|
||||
|
@ -97,7 +97,7 @@ func (t SanitizerType) variationName() string {
|
|||
switch t {
|
||||
case Asan:
|
||||
return "asan"
|
||||
case hwasan:
|
||||
case Hwasan:
|
||||
return "hwasan"
|
||||
case tsan:
|
||||
return "tsan"
|
||||
|
@ -121,7 +121,7 @@ func (t SanitizerType) name() string {
|
|||
switch t {
|
||||
case Asan:
|
||||
return "address"
|
||||
case hwasan:
|
||||
case Hwasan:
|
||||
return "hwaddress"
|
||||
case memtag_heap:
|
||||
return "memtag_heap"
|
||||
|
@ -144,7 +144,7 @@ func (*Module) SanitizerSupported(t SanitizerType) bool {
|
|||
switch t {
|
||||
case Asan:
|
||||
return true
|
||||
case hwasan:
|
||||
case Hwasan:
|
||||
return true
|
||||
case tsan:
|
||||
return true
|
||||
|
@ -163,7 +163,7 @@ func (*Module) SanitizerSupported(t SanitizerType) bool {
|
|||
|
||||
// incompatibleWithCfi returns true if a sanitizer is incompatible with CFI.
|
||||
func (t SanitizerType) incompatibleWithCfi() bool {
|
||||
return t == Asan || t == Fuzzer || t == hwasan
|
||||
return t == Asan || t == Fuzzer || t == Hwasan
|
||||
}
|
||||
|
||||
type SanitizeUserProps struct {
|
||||
|
@ -745,7 +745,7 @@ func (sanitize *sanitize) getSanitizerBoolPtr(t SanitizerType) *bool {
|
|||
switch t {
|
||||
case Asan:
|
||||
return sanitize.Properties.Sanitize.Address
|
||||
case hwasan:
|
||||
case Hwasan:
|
||||
return sanitize.Properties.Sanitize.Hwaddress
|
||||
case tsan:
|
||||
return sanitize.Properties.Sanitize.Thread
|
||||
|
@ -767,7 +767,7 @@ func (sanitize *sanitize) getSanitizerBoolPtr(t SanitizerType) *bool {
|
|||
// isUnsanitizedVariant returns true if no sanitizers are enabled.
|
||||
func (sanitize *sanitize) isUnsanitizedVariant() bool {
|
||||
return !sanitize.isSanitizerEnabled(Asan) &&
|
||||
!sanitize.isSanitizerEnabled(hwasan) &&
|
||||
!sanitize.isSanitizerEnabled(Hwasan) &&
|
||||
!sanitize.isSanitizerEnabled(tsan) &&
|
||||
!sanitize.isSanitizerEnabled(cfi) &&
|
||||
!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).
|
||||
func (sanitize *sanitize) isVariantOnProductionDevice() bool {
|
||||
return !sanitize.isSanitizerEnabled(Asan) &&
|
||||
!sanitize.isSanitizerEnabled(hwasan) &&
|
||||
!sanitize.isSanitizerEnabled(Hwasan) &&
|
||||
!sanitize.isSanitizerEnabled(tsan) &&
|
||||
!sanitize.isSanitizerEnabled(Fuzzer)
|
||||
}
|
||||
|
@ -787,7 +787,7 @@ func (sanitize *sanitize) SetSanitizer(t SanitizerType, b bool) {
|
|||
switch t {
|
||||
case Asan:
|
||||
sanitize.Properties.Sanitize.Address = boolPtr(b)
|
||||
case hwasan:
|
||||
case Hwasan:
|
||||
sanitize.Properties.Sanitize.Hwaddress = boolPtr(b)
|
||||
case tsan:
|
||||
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() &&
|
||||
!d.SanitizeNever() &&
|
||||
!d.IsSanitizerExplicitlyDisabled(t) {
|
||||
if t == cfi || t == hwasan || t == scs {
|
||||
if t == cfi || t == Hwasan || t == scs {
|
||||
if d.StaticallyLinked() && d.SanitizerSupported(t) {
|
||||
// Rust does not support some of these sanitizers, so we need to check if it's
|
||||
// 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
|
||||
// to Make, because the sanitized version has a different suffix in name.
|
||||
// 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 {
|
||||
modules[0].(PlatformSanitizeable).SetPreventInstall()
|
||||
modules[0].(PlatformSanitizeable).SetHideFromMake()
|
||||
|
@ -1294,7 +1294,7 @@ func sanitizerMutator(t SanitizerType) func(android.BottomUpMutatorContext) {
|
|||
if c.StaticallyLinked() && c.ExportedToMake() {
|
||||
if t == cfi {
|
||||
cfiStaticLibs(mctx.Config()).add(c, c.Module().Name())
|
||||
} else if t == hwasan {
|
||||
} else if t == Hwasan {
|
||||
hwasanStaticLibs(mctx.Config()).add(c, c.Module().Name())
|
||||
}
|
||||
}
|
||||
|
@ -1411,7 +1411,7 @@ var hwasanStaticLibsKey = android.NewOnceKey("hwasanStaticLibs")
|
|||
|
||||
func hwasanStaticLibs(config android.Config) *sanitizerStaticLibsMap {
|
||||
return config.Once(hwasanStaticLibsKey, func() interface{} {
|
||||
return newSanitizerStaticLibsMap(hwasan)
|
||||
return newSanitizerStaticLibsMap(Hwasan)
|
||||
}).(*sanitizerStaticLibsMap)
|
||||
}
|
||||
|
||||
|
|
|
@ -196,7 +196,7 @@ func isSnapshotAware(cfg android.DeviceConfig, m *Module, inProprietaryPath bool
|
|||
if m.sanitize != nil {
|
||||
// scs and hwasan export both sanitized and unsanitized variants for static and header
|
||||
// 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) {
|
||||
return false
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue