diff options
-rw-r--r-- | cc/sanitize.go | 21 | ||||
-rw-r--r-- | cc/snapshot_prebuilt.go | 4 | ||||
-rw-r--r-- | cc/vendor_snapshot_test.go | 43 |
3 files changed, 55 insertions, 13 deletions
diff --git a/cc/sanitize.go b/cc/sanitize.go index dc073817b..8e2d16183 100644 --- a/cc/sanitize.go +++ b/cc/sanitize.go @@ -630,15 +630,8 @@ func (sanitize *sanitize) begin(ctx BaseModuleContext) { // Also disable CFI for VNDK variants of components if ctx.isVndk() && ctx.useVndk() { - if ctx.static() { - // Cfi variant for static vndk should be captured as vendor snapshot, - // so don't strictly disable Cfi. - s.Cfi = nil - s.Diag.Cfi = nil - } else { - s.Cfi = nil - s.Diag.Cfi = nil - } + s.Cfi = nil + s.Diag.Cfi = nil } // HWASan ramdisk (which is built from recovery) goes over some bootloader limit. @@ -1168,10 +1161,12 @@ func (s *sanitizerSplitMutator) Split(ctx android.BaseModuleContext) []string { //TODO: When Rust modules have vendor support, enable this path for PlatformSanitizeable // Check if it's a snapshot module supporting sanitizer - if ss, ok := c.linker.(snapshotSanitizer); ok && ss.isSanitizerAvailable(s.sanitizer) { - return []string{"", s.sanitizer.variationName()} - } else { - return []string{""} + if ss, ok := c.linker.(snapshotSanitizer); ok { + if ss.isSanitizerAvailable(s.sanitizer) { + return []string{"", s.sanitizer.variationName()} + } else { + return []string{""} + } } } diff --git a/cc/snapshot_prebuilt.go b/cc/snapshot_prebuilt.go index 570300b91..32878ca3f 100644 --- a/cc/snapshot_prebuilt.go +++ b/cc/snapshot_prebuilt.go @@ -801,6 +801,10 @@ func VendorSnapshotObjectFactory() android.Module { prebuilt.Init(module, VendorSnapshotImageSingleton, snapshotObjectSuffix) module.AddProperties(&prebuilt.properties) + + // vendor_snapshot_object module does not provide sanitizer variants + module.sanitize.Properties.Sanitize.Never = BoolPtr(true) + return module.Init() } diff --git a/cc/vendor_snapshot_test.go b/cc/vendor_snapshot_test.go index 79405e9c4..619500e1d 100644 --- a/cc/vendor_snapshot_test.go +++ b/cc/vendor_snapshot_test.go @@ -1050,6 +1050,12 @@ func TestVendorSnapshotSanitizer(t *testing.T) { "libsnapshot", "note_memtag_heap_sync", ], + objects: [ + "snapshot_object", + ], + vndk_libs: [ + "libclang_rt.hwasan", + ], }, }, } @@ -1084,6 +1090,35 @@ func TestVendorSnapshotSanitizer(t *testing.T) { }, } + vndk_prebuilt_shared { + name: "libclang_rt.hwasan", + version: "28", + target_arch: "arm64", + vendor_available: true, + product_available: true, + vndk: { + enabled: true, + }, + arch: { + arm64: { + srcs: ["libclang_rt.hwasan.so"], + }, + }, + } + + vendor_snapshot_object { + name: "snapshot_object", + vendor: true, + target_arch: "arm64", + version: "28", + arch: { + arm64: { + src: "snapshot_object.o", + }, + }, + stl: "none", + } + cc_test { name: "vstest", gtest: false, @@ -1100,15 +1135,18 @@ func TestVendorSnapshotSanitizer(t *testing.T) { mockFS := map[string][]byte{ "vendor/Android.bp": []byte(bp), "vendor/libc++demangle.a": nil, + "vendor/libclang_rt.hwasan.so": nil, "vendor/libsnapshot.a": nil, "vendor/libsnapshot.cfi.a": nil, "vendor/libsnapshot.hwasan.a": nil, "vendor/note_memtag_heap_sync.a": nil, + "vendor/snapshot_object.o": nil, } config := TestConfig(t.TempDir(), android.Android, nil, "", mockFS) config.TestProductVariables.DeviceVndkVersion = StringPtr("28") config.TestProductVariables.Platform_vndk_version = StringPtr("29") + config.TestProductVariables.SanitizeDevice = []string{"hwaddress"} ctx := testCcWithConfig(t, config) // Check non-cfi, cfi and hwasan variant. @@ -1130,6 +1168,11 @@ func TestVendorSnapshotSanitizer(t *testing.T) { if !staticHwasanCfiModule.HiddenFromMake() || !staticHwasanCfiModule.PreventInstall() { t.Errorf("Hwasan and Cfi cannot enabled at the same time.") } + + snapshotObjModule := ctx.ModuleForTests("snapshot_object.vendor_object.28.arm64", "android_vendor.28_arm64_armv8-a").Module() + snapshotObjMkEntries := android.AndroidMkEntriesForTest(t, ctx, snapshotObjModule) + // snapshot object must not add ".hwasan" suffix + assertString(t, snapshotObjMkEntries[0].EntryMap["LOCAL_MODULE"][0], "snapshot_object") } func TestVendorSnapshotExclude(t *testing.T) { |