summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Justin Yun <justinyun@google.com> 2022-12-15 21:45:35 +0900
committer Justin Yun <justinyun@google.com> 2022-12-19 17:18:22 +0900
commit8814fc5c207bcfa3ba7d4c794249d67cc2688251 (patch)
treeac6b8a239ebee4f99f40282b0d7574eea58cb89b
parentabc182cc94a7a794ea71e19704793cdc517f7e58 (diff)
VSDK: capture hwasan static libs for vsdk snapshot build
When generating vsdk snapshot with SANITIZE_TARGET=hwaddress option, include hwasan static libraries to the vendor snapshot. Bug: 234772527 Test: build against the vsdk with SANITIZE_TARGET=hwaddress Change-Id: I6fdecefaa8557b5c968745487a3ed7c959e682f9
-rw-r--r--cc/sanitize.go5
-rw-r--r--cc/vendor_snapshot.go43
2 files changed, 31 insertions, 17 deletions
diff --git a/cc/sanitize.go b/cc/sanitize.go
index eba709bc2..dc073817b 100644
--- a/cc/sanitize.go
+++ b/cc/sanitize.go
@@ -1067,6 +1067,11 @@ func (m *Module) SanitizableDepTagChecker() SantizableDependencyTagChecker {
// as vendor snapshot. Such modules must create both cfi and non-cfi variants,
// except for ones which explicitly disable cfi.
func needsCfiForVendorSnapshot(mctx android.BaseModuleContext) bool {
+ if inList("hwaddress", mctx.Config().SanitizeDevice()) {
+ // cfi will not be built if SANITIZE_TARGET=hwaddress is set
+ return false
+ }
+
if snapshot.IsVendorProprietaryModule(mctx) {
return false
}
diff --git a/cc/vendor_snapshot.go b/cc/vendor_snapshot.go
index 2dcf26eac..9b12bfa18 100644
--- a/cc/vendor_snapshot.go
+++ b/cc/vendor_snapshot.go
@@ -93,17 +93,18 @@ func isSnapshotAware(cfg android.DeviceConfig, m LinkableInterface, inProprietar
// Libraries
if sanitizable, ok := m.(PlatformSanitizeable); ok && sanitizable.IsSnapshotLibrary() {
if sanitizable.SanitizePropDefined() {
- // 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} {
- if !sanitizable.Shared() && sanitizable.IsSanitizerEnabled(t) {
- return false
- }
+ // scs exports both sanitized and unsanitized variants for static and header
+ // Always use unsanitized variant of it.
+ if !sanitizable.Shared() && sanitizable.IsSanitizerEnabled(scs) {
+ return false
}
- // cfi also exports both variants. But for static, we capture both.
+ // cfi and hwasan also export both variants. But for static, we capture both.
// This is because cfi static libraries can't be linked from non-cfi modules,
- // and vice versa. This isn't the case for scs and hwasan sanitizers.
- if !sanitizable.Static() && !sanitizable.Shared() && sanitizable.IsSanitizerEnabled(cfi) {
+ // and vice versa.
+ // hwasan is captured as well to support hwasan build.
+ if !sanitizable.Static() &&
+ !sanitizable.Shared() &&
+ (sanitizable.IsSanitizerEnabled(cfi) || sanitizable.IsSanitizerEnabled(Hwasan)) {
return false
}
}
@@ -303,14 +304,22 @@ var ccSnapshotAction snapshot.GenerateSnapshotAction = func(s snapshot.SnapshotS
libPath := m.OutputFile().Path()
stem = libPath.Base()
if sanitizable, ok := m.(PlatformSanitizeable); ok {
- if (sanitizable.Static() || sanitizable.Rlib()) && sanitizable.SanitizePropDefined() && sanitizable.IsSanitizerEnabled(cfi) {
- // both cfi and non-cfi variant for static libraries can exist.
- // attach .cfi to distinguish between cfi and non-cfi.
- // e.g. libbase.a -> libbase.cfi.a
- ext := filepath.Ext(stem)
- stem = strings.TrimSuffix(stem, ext) + ".cfi" + ext
- prop.Sanitize = "cfi"
- prop.ModuleName += ".cfi"
+ if (sanitizable.Static() || sanitizable.Rlib()) && sanitizable.SanitizePropDefined() {
+ if sanitizable.IsSanitizerEnabled(cfi) {
+ // both cfi and non-cfi variant for static libraries can exist.
+ // attach .cfi to distinguish between cfi and non-cfi.
+ // e.g. libbase.a -> libbase.cfi.a
+ ext := filepath.Ext(stem)
+ stem = strings.TrimSuffix(stem, ext) + ".cfi" + ext
+ prop.Sanitize = "cfi"
+ prop.ModuleName += ".cfi"
+ } else if sanitizable.IsSanitizerEnabled(Hwasan) {
+ // Same for the hwasan
+ ext := filepath.Ext(stem)
+ stem = strings.TrimSuffix(stem, ext) + ".hwasan" + ext
+ prop.Sanitize = "hwasan"
+ prop.ModuleName += ".hwasan"
+ }
}
}
snapshotLibOut := filepath.Join(snapshotArchDir, targetArch, libType, stem)