Explicitly disable CFI in bp2build when false
In Soong, CFI being explicitly set to false overrides presence in CFI_INCLUDE_PATHS, so this change causes Bazel to mimic the same precedence. Bug: 278789968 Test: Unit tests Change-Id: I827b3d4272eac2002031970f1e67c9321979b14b
This commit is contained in:
@@ -1126,6 +1126,26 @@ func TestCcBinaryWithCfiAndCfiAssemblySupport(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestCcBinaryExplicitlyDisablesCfiWhenFalse(t *testing.T) {
|
||||
runCcBinaryTestCase(t, ccBinaryBp2buildTestCase{
|
||||
description: "cc_binary disables cfi when explciitly set to false in the bp",
|
||||
blueprint: `
|
||||
{rule_name} {
|
||||
name: "foo",
|
||||
sanitize: {
|
||||
cfi: false,
|
||||
},
|
||||
}
|
||||
`,
|
||||
targets: []testBazelTarget{
|
||||
{"cc_binary", "foo", AttrNameToString{
|
||||
"features": `["-android_cfi"]`,
|
||||
"local_includes": `["."]`,
|
||||
}},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func TestCcBinaryStem(t *testing.T) {
|
||||
runCcBinaryTestCase(t, ccBinaryBp2buildTestCase{
|
||||
description: "cc_binary with stem property",
|
||||
|
@@ -4839,6 +4839,32 @@ cc_library {
|
||||
})
|
||||
}
|
||||
|
||||
func TestCcLibraryExplicitlyDisablesCfiWhenFalse(t *testing.T) {
|
||||
runCcLibraryTestCase(t, Bp2buildTestCase{
|
||||
Description: "cc_library disables cfi when explciitly set to false in the bp",
|
||||
ModuleTypeUnderTest: "cc_library",
|
||||
ModuleTypeUnderTestFactory: cc.LibraryFactory,
|
||||
Blueprint: `
|
||||
cc_library {
|
||||
name: "foo",
|
||||
sanitize: {
|
||||
cfi: false,
|
||||
},
|
||||
}
|
||||
`,
|
||||
ExpectedBazelTargets: []string{
|
||||
MakeBazelTarget("cc_library_static", "foo_bp2build_cc_library_static", AttrNameToString{
|
||||
"features": `["-android_cfi"]`,
|
||||
"local_includes": `["."]`,
|
||||
}),
|
||||
MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{
|
||||
"features": `["-android_cfi"]`,
|
||||
"local_includes": `["."]`,
|
||||
}),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func TestCcLibraryWithStem(t *testing.T) {
|
||||
runCcLibraryTestCase(t, Bp2buildTestCase{
|
||||
Description: "cc_library with stem property",
|
||||
|
@@ -1535,3 +1535,23 @@ cc_library_static {
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func TestCcLibrarySharedExplicitlyDisablesCfiWhenFalse(t *testing.T) {
|
||||
runCcLibrarySharedTestCase(t, Bp2buildTestCase{
|
||||
Description: "cc_library_shared disables cfi when explciitly set to false in the bp",
|
||||
Blueprint: `
|
||||
cc_library_shared {
|
||||
name: "foo",
|
||||
sanitize: {
|
||||
cfi: false,
|
||||
},
|
||||
}
|
||||
`,
|
||||
ExpectedBazelTargets: []string{
|
||||
MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{
|
||||
"features": `["-android_cfi"]`,
|
||||
"local_includes": `["."]`,
|
||||
}),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
@@ -2165,3 +2165,23 @@ cc_library_static {
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func TestCcLibraryStaticExplicitlyDisablesCfiWhenFalse(t *testing.T) {
|
||||
runCcLibraryStaticTestCase(t, Bp2buildTestCase{
|
||||
Description: "cc_library_static disables cfi when explciitly set to false in the bp",
|
||||
Blueprint: `
|
||||
cc_library_static {
|
||||
name: "foo",
|
||||
sanitize: {
|
||||
cfi: false,
|
||||
},
|
||||
}
|
||||
`,
|
||||
ExpectedBazelTargets: []string{
|
||||
MakeBazelTarget("cc_library_static", "foo", AttrNameToString{
|
||||
"features": `["-android_cfi"]`,
|
||||
"local_includes": `["."]`,
|
||||
}),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
@@ -1787,7 +1787,9 @@ func bp2buildSanitizerFeatures(ctx android.BazelConversionPathContext, m *Module
|
||||
blocklistFeatureSuffix := strings.Replace(strings.ToLower(*blocklist), ".", "_", -1)
|
||||
features = append(features, "ubsan_blocklist_"+blocklistFeatureSuffix)
|
||||
}
|
||||
if proptools.Bool(sanitizerProps.Sanitize.Cfi) {
|
||||
if sanitizerProps.Sanitize.Cfi != nil && !proptools.Bool(sanitizerProps.Sanitize.Cfi) {
|
||||
features = append(features, "-android_cfi")
|
||||
} else if proptools.Bool(sanitizerProps.Sanitize.Cfi) {
|
||||
features = append(features, "android_cfi")
|
||||
if proptools.Bool(sanitizerProps.Sanitize.Config.Cfi_assembly_support) {
|
||||
features = append(features, "android_cfi_assembly_support")
|
||||
|
Reference in New Issue
Block a user