Loading android/config.go +21 −0 Original line number Diff line number Diff line Loading @@ -1256,6 +1256,27 @@ func (c *config) CFIEnabledForPath(path string) bool { return HasAnyPrefix(path, c.productVariables.CFIIncludePaths) } func (c *config) MemtagHeapDisabledForPath(path string) bool { if len(c.productVariables.MemtagHeapExcludePaths) == 0 { return false } return HasAnyPrefix(path, c.productVariables.MemtagHeapExcludePaths) } func (c *config) MemtagHeapAsyncEnabledForPath(path string) bool { if len(c.productVariables.MemtagHeapAsyncIncludePaths) == 0 { return false } return HasAnyPrefix(path, c.productVariables.MemtagHeapAsyncIncludePaths) } func (c *config) MemtagHeapSyncEnabledForPath(path string) bool { if len(c.productVariables.MemtagHeapSyncIncludePaths) == 0 { return false } return HasAnyPrefix(path, c.productVariables.MemtagHeapSyncIncludePaths) } func (c *config) VendorConfig(name string) VendorConfig { return soongconfig.Config(c.productVariables.VendorVars[name]) } Loading android/variable.go +4 −0 Original line number Diff line number Diff line Loading @@ -260,6 +260,10 @@ type productVariables struct { DisableScudo *bool `json:",omitempty"` MemtagHeapExcludePaths []string `json:",omitempty"` MemtagHeapAsyncIncludePaths []string `json:",omitempty"` MemtagHeapSyncIncludePaths []string `json:",omitempty"` VendorPath *string `json:",omitempty"` OdmPath *string `json:",omitempty"` ProductPath *string `json:",omitempty"` Loading cc/cc_test.go +35 −2 Original line number Diff line number Diff line Loading @@ -4483,7 +4483,7 @@ func checkDoesNotHaveImplicitDep(t *testing.T, m android.TestingModule, name str } func TestSanitizeMemtagHeap(t *testing.T) { ctx := testCc(t, ` rootBp := ` cc_library_static { name: "libstatic", sanitize: { memtag_heap: true }, Loading Loading @@ -4543,7 +4543,37 @@ func TestSanitizeMemtagHeap(t *testing.T) { sanitize: { memtag_heap: true, diag: { memtag_heap: false } }, } `) ` subdirAsyncBp := ` cc_binary { name: "binary_async", } ` subdirSyncBp := ` cc_binary { name: "binary_sync", } ` mockFS := map[string][]byte{ "subdir_async/Android.bp": []byte(subdirAsyncBp), "subdir_sync/Android.bp": []byte(subdirSyncBp), } config := TestConfig(buildDir, android.Android, nil, rootBp, mockFS) config.TestProductVariables.DeviceVndkVersion = StringPtr("current") config.TestProductVariables.Platform_vndk_version = StringPtr("VER") config.TestProductVariables.MemtagHeapAsyncIncludePaths = []string{"subdir_async"} config.TestProductVariables.MemtagHeapSyncIncludePaths = []string{"subdir_sync"} ctx := CreateTestContext(config) ctx.Register() _, errs := ctx.ParseFileList(".", []string{"Android.bp", "subdir_sync/Android.bp", "subdir_async/Android.bp"}) android.FailIfErrored(t, errs) _, errs = ctx.PrepareBuildActions(config) android.FailIfErrored(t, errs) variant := "android_arm64_armv8-a" note_async := "note_memtag_heap_async" Loading @@ -4562,4 +4592,7 @@ func TestSanitizeMemtagHeap(t *testing.T) { checkHasImplicitDep(t, ctx.ModuleForTests("test_true", variant), note_async) checkDoesNotHaveImplicitDep(t, ctx.ModuleForTests("test_false", variant), note_any) checkHasImplicitDep(t, ctx.ModuleForTests("test_true_async", variant), note_async) checkHasImplicitDep(t, ctx.ModuleForTests("binary_async", variant), note_async) checkHasImplicitDep(t, ctx.ModuleForTests("binary_sync", variant), note_sync) } cc/sanitize.go +18 −3 Original line number Diff line number Diff line Loading @@ -338,8 +338,10 @@ func (sanitize *sanitize) begin(ctx BaseModuleContext) { s.Writeonly = boolPtr(true) } if found, globalSanitizers = removeFromList("memtag_heap", globalSanitizers); found && s.Memtag_heap == nil { if !ctx.Config().MemtagHeapDisabledForPath(ctx.ModuleDir()) { s.Memtag_heap = boolPtr(true) } } if len(globalSanitizers) > 0 { ctx.ModuleErrorf("unknown global sanitizer option %s", globalSanitizers[0]) Loading @@ -363,8 +365,21 @@ func (sanitize *sanitize) begin(ctx BaseModuleContext) { // cc_test targets default to SYNC MemTag. if ctx.testBinary() && s.Memtag_heap == nil { if !ctx.Config().MemtagHeapDisabledForPath(ctx.ModuleDir()) { s.Memtag_heap = boolPtr(true) s.Diag.Memtag_heap = boolPtr(true) } } // Enable Memtag for all components in the include paths (for Aarch64 only) if s.Memtag_heap == nil && ctx.Arch().ArchType == android.Arm64 { if ctx.Config().MemtagHeapSyncEnabledForPath(ctx.ModuleDir()) { s.Memtag_heap = boolPtr(true) s.Diag.Memtag_heap = boolPtr(true) } else if ctx.Config().MemtagHeapAsyncEnabledForPath(ctx.ModuleDir()) { s.Memtag_heap = boolPtr(true) s.Diag.Memtag_heap = boolPtr(false) } } // Enable CFI for all components in the include paths (for Aarch64 only) Loading Loading
android/config.go +21 −0 Original line number Diff line number Diff line Loading @@ -1256,6 +1256,27 @@ func (c *config) CFIEnabledForPath(path string) bool { return HasAnyPrefix(path, c.productVariables.CFIIncludePaths) } func (c *config) MemtagHeapDisabledForPath(path string) bool { if len(c.productVariables.MemtagHeapExcludePaths) == 0 { return false } return HasAnyPrefix(path, c.productVariables.MemtagHeapExcludePaths) } func (c *config) MemtagHeapAsyncEnabledForPath(path string) bool { if len(c.productVariables.MemtagHeapAsyncIncludePaths) == 0 { return false } return HasAnyPrefix(path, c.productVariables.MemtagHeapAsyncIncludePaths) } func (c *config) MemtagHeapSyncEnabledForPath(path string) bool { if len(c.productVariables.MemtagHeapSyncIncludePaths) == 0 { return false } return HasAnyPrefix(path, c.productVariables.MemtagHeapSyncIncludePaths) } func (c *config) VendorConfig(name string) VendorConfig { return soongconfig.Config(c.productVariables.VendorVars[name]) } Loading
android/variable.go +4 −0 Original line number Diff line number Diff line Loading @@ -260,6 +260,10 @@ type productVariables struct { DisableScudo *bool `json:",omitempty"` MemtagHeapExcludePaths []string `json:",omitempty"` MemtagHeapAsyncIncludePaths []string `json:",omitempty"` MemtagHeapSyncIncludePaths []string `json:",omitempty"` VendorPath *string `json:",omitempty"` OdmPath *string `json:",omitempty"` ProductPath *string `json:",omitempty"` Loading
cc/cc_test.go +35 −2 Original line number Diff line number Diff line Loading @@ -4483,7 +4483,7 @@ func checkDoesNotHaveImplicitDep(t *testing.T, m android.TestingModule, name str } func TestSanitizeMemtagHeap(t *testing.T) { ctx := testCc(t, ` rootBp := ` cc_library_static { name: "libstatic", sanitize: { memtag_heap: true }, Loading Loading @@ -4543,7 +4543,37 @@ func TestSanitizeMemtagHeap(t *testing.T) { sanitize: { memtag_heap: true, diag: { memtag_heap: false } }, } `) ` subdirAsyncBp := ` cc_binary { name: "binary_async", } ` subdirSyncBp := ` cc_binary { name: "binary_sync", } ` mockFS := map[string][]byte{ "subdir_async/Android.bp": []byte(subdirAsyncBp), "subdir_sync/Android.bp": []byte(subdirSyncBp), } config := TestConfig(buildDir, android.Android, nil, rootBp, mockFS) config.TestProductVariables.DeviceVndkVersion = StringPtr("current") config.TestProductVariables.Platform_vndk_version = StringPtr("VER") config.TestProductVariables.MemtagHeapAsyncIncludePaths = []string{"subdir_async"} config.TestProductVariables.MemtagHeapSyncIncludePaths = []string{"subdir_sync"} ctx := CreateTestContext(config) ctx.Register() _, errs := ctx.ParseFileList(".", []string{"Android.bp", "subdir_sync/Android.bp", "subdir_async/Android.bp"}) android.FailIfErrored(t, errs) _, errs = ctx.PrepareBuildActions(config) android.FailIfErrored(t, errs) variant := "android_arm64_armv8-a" note_async := "note_memtag_heap_async" Loading @@ -4562,4 +4592,7 @@ func TestSanitizeMemtagHeap(t *testing.T) { checkHasImplicitDep(t, ctx.ModuleForTests("test_true", variant), note_async) checkDoesNotHaveImplicitDep(t, ctx.ModuleForTests("test_false", variant), note_any) checkHasImplicitDep(t, ctx.ModuleForTests("test_true_async", variant), note_async) checkHasImplicitDep(t, ctx.ModuleForTests("binary_async", variant), note_async) checkHasImplicitDep(t, ctx.ModuleForTests("binary_sync", variant), note_sync) }
cc/sanitize.go +18 −3 Original line number Diff line number Diff line Loading @@ -338,8 +338,10 @@ func (sanitize *sanitize) begin(ctx BaseModuleContext) { s.Writeonly = boolPtr(true) } if found, globalSanitizers = removeFromList("memtag_heap", globalSanitizers); found && s.Memtag_heap == nil { if !ctx.Config().MemtagHeapDisabledForPath(ctx.ModuleDir()) { s.Memtag_heap = boolPtr(true) } } if len(globalSanitizers) > 0 { ctx.ModuleErrorf("unknown global sanitizer option %s", globalSanitizers[0]) Loading @@ -363,8 +365,21 @@ func (sanitize *sanitize) begin(ctx BaseModuleContext) { // cc_test targets default to SYNC MemTag. if ctx.testBinary() && s.Memtag_heap == nil { if !ctx.Config().MemtagHeapDisabledForPath(ctx.ModuleDir()) { s.Memtag_heap = boolPtr(true) s.Diag.Memtag_heap = boolPtr(true) } } // Enable Memtag for all components in the include paths (for Aarch64 only) if s.Memtag_heap == nil && ctx.Arch().ArchType == android.Arm64 { if ctx.Config().MemtagHeapSyncEnabledForPath(ctx.ModuleDir()) { s.Memtag_heap = boolPtr(true) s.Diag.Memtag_heap = boolPtr(true) } else if ctx.Config().MemtagHeapAsyncEnabledForPath(ctx.ModuleDir()) { s.Memtag_heap = boolPtr(true) s.Diag.Memtag_heap = boolPtr(false) } } // Enable CFI for all components in the include paths (for Aarch64 only) Loading