Merge "Add CFI flags to Compile Action"

This commit is contained in:
Yu Liu 2023-06-05 22:47:52 +00:00 committed by Gerrit Code Review
commit e0a7318331

View file

@ -64,13 +64,14 @@ var (
cfiBlocklistPath = "external/compiler-rt/lib/cfi"
cfiBlocklistFilename = "cfi_blocklist.txt"
cfiEnableFlag = "-fsanitize=cfi"
cfiCrossDsoFlag = "-fsanitize-cfi-cross-dso"
cfiCflags = []string{"-flto", cfiCrossDsoFlag,
"-fsanitize-ignorelist=" + cfiBlocklistPath + "/" + cfiBlocklistFilename}
// -flto and -fvisibility are required by clang when -fsanitize=cfi is
// used, but have no effect on assembly files
cfiAsflags = []string{"-flto", "-fvisibility=default"}
cfiLdflags = []string{"-flto", cfiCrossDsoFlag, "-fsanitize=cfi",
cfiLdflags = []string{"-flto", cfiCrossDsoFlag, cfiEnableFlag,
"-Wl,-plugin-opt,O1"}
cfiExportsMapPath = "build/soong/cc/config"
cfiExportsMapFilename = "cfi_exports.map"
@ -395,8 +396,8 @@ func init() {
// Leave out "-flto" from the slices exported to bazel, as we will use the
// dedicated LTO feature for this. For C Flags and Linker Flags, also leave
// out the cross DSO flag which will be added separately by transitions.
exportedVars.ExportStringList("CfiCFlags", cfiCflags[2:])
// out the cross DSO flag which will be added separately under the correct conditions.
exportedVars.ExportStringList("CfiCFlags", append(cfiCflags[2:], cfiEnableFlag))
exportedVars.ExportStringList("CfiLdFlags", cfiLdflags[2:])
exportedVars.ExportStringList("CfiAsFlags", cfiAsflags[1:])