CFI Versionscript changes in bp2build

Bug: 261733820
Test: Unit Tests
Change-Id: I0bf2f42944738c0fefb10e59e859d2af44402792
This commit is contained in:
Trevor Radcliffe 2023-05-19 14:51:41 +00:00
parent 3daa129afa
commit f06dd91420
4 changed files with 17 additions and 2 deletions

View file

@ -222,6 +222,7 @@ func TestCcBinaryVersionScriptAndDynamicList(t *testing.T) {
"-Wl,--version-script,$(location vs)",
"-Wl,--dynamic-list,$(location dynamic.list)",
]`,
"features": `["android_cfi_exports_map"]`,
},
},
},
@ -249,6 +250,7 @@ func TestCcBinaryLdflagsSplitBySpaceExceptSoongAdded(t *testing.T) {
"version_script",
"dynamic.list",
]`,
"features": `["android_cfi_exports_map"]`,
"linkopts": `[
"--nospace_flag",
"-z",

View file

@ -900,7 +900,8 @@ cc_library {
"-Wl,--version-script,$(location v.map)",
"-Wl,--dynamic-list,$(location dynamic.list)",
]`,
"srcs": `["a.cpp"]`,
"srcs": `["a.cpp"]`,
"features": `["android_cfi_exports_map"]`,
}),
},
)
@ -958,6 +959,11 @@ cc_library {
"//conditions:default": [],
})`,
"srcs": `["a.cpp"]`,
"features": `select({
"//build/bazel/platforms/arch:arm": ["android_cfi_exports_map"],
"//build/bazel/platforms/arch:arm64": ["android_cfi_exports_map"],
"//conditions:default": [],
})`,
}),
},
)
@ -985,12 +991,15 @@ cc_library {
}
`,
ExpectedBazelTargets: []string{
MakeBazelTarget("cc_library_static", "foo_bp2build_cc_library_static", AttrNameToString{}),
MakeBazelTarget("cc_library_static", "foo_bp2build_cc_library_static", AttrNameToString{
"features": `["android_cfi_exports_map"]`,
}),
MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{
"additional_linker_inputs": `[
"version_script",
"dynamic.list",
]`,
"features": `["android_cfi_exports_map"]`,
"linkopts": `[
"--nospace_flag",
"-z",

View file

@ -362,6 +362,7 @@ cc_library_shared {
"-Wl,--version-script,$(location version_script)",
"-Wl,--dynamic-list,$(location dynamic.list)",
]`,
"features": `["android_cfi_exports_map"]`,
}),
},
})
@ -398,6 +399,7 @@ cc_library_shared {
"-Wl,--version-script,$(location version_script)",
"-Wl,--dynamic-list,$(location dynamic.list)",
]`,
"features": `["android_cfi_exports_map"]`,
}),
},
})
@ -913,6 +915,7 @@ func TestCCLibraryFlagSpaceSplitting(t *testing.T) {
"header.h",
]`,
"linkopts": `["-Wl,--version-script,$(location version_script)"]`,
"features": `["android_cfi_exports_map"]`,
}),
},
})

View file

@ -1257,6 +1257,7 @@ func (la *linkerAttributes) bp2buildForAxisAndConfig(ctx android.BazelConversion
label := android.BazelLabelForModuleSrcSingle(ctx, *props.Version_script)
additionalLinkerInputs.Add(&label)
linkerFlags = append(linkerFlags, fmt.Sprintf("-Wl,--version-script,$(location %s)", label.Label))
axisFeatures = append(axisFeatures, "android_cfi_exports_map")
}
if props.Dynamic_list != nil {