Merge "Move gen_sorted_bss_symbols.sh to use LLVM binutils"

This commit is contained in:
Yi Kong 2021-04-01 03:10:08 +00:00 committed by Gerrit Code Review
commit 9d9e053964
2 changed files with 6 additions and 7 deletions

View File

@ -599,21 +599,20 @@ var (
_ = pctx.SourcePathVariable("genSortedBssSymbolsPath", "build/soong/scripts/gen_sorted_bss_symbols.sh")
genSortedBssSymbols = pctx.AndroidStaticRule("gen_sorted_bss_symbols",
blueprint.RuleParams{
Command: "CROSS_COMPILE=$crossCompile $genSortedBssSymbolsPath ${in} ${out}",
CommandDeps: []string{"$genSortedBssSymbolsPath", "${crossCompile}nm"},
Command: "CLANG_BIN=${clangBin} $genSortedBssSymbolsPath ${in} ${out}",
CommandDeps: []string{"$genSortedBssSymbolsPath", "${clangBin}/llvm-nm"},
},
"crossCompile")
"clangBin")
)
func (linker *baseLinker) sortBssSymbolsBySize(ctx ModuleContext, in android.Path, symbolOrderingFile android.ModuleOutPath, flags builderFlags) string {
crossCompile := gccCmd(flags.toolchain, "")
ctx.Build(pctx, android.BuildParams{
Rule: genSortedBssSymbols,
Description: "generate bss symbol order " + symbolOrderingFile.Base(),
Output: symbolOrderingFile,
Input: in,
Args: map[string]string{
"crossCompile": crossCompile,
"clangBin": "${config.ClangBin}",
},
})
return "-Wl,--symbol-ordering-file," + symbolOrderingFile.String()

View File

@ -18,11 +18,11 @@
# their sizes.
# Inputs:
# Environment:
# CROSS_COMPILE: prefix added to nm tools
# CLANG_BIN: path to the clang bin directory
# Arguments:
# $1: Input ELF file
# $2: Output symbol ordering file
set -o pipefail
${CROSS_COMPILE}nm --size-sort $1 | awk '{if ($2 == "b" || $2 == "B") print $3}' > $2
${CLANG_BIN}/llvm-nm --size-sort $1 | awk '{if ($2 == "b" || $2 == "B") print $3}' > $2