Move gen_sorted_bss_symbols.sh to use LLVM binutils

Test: build
Change-Id: I496b92d963d127087daef405dafa24377d6bac97
This commit is contained in:
Yi Kong 2021-03-31 17:12:40 +08:00
parent 32eccae1ac
commit bf1db7b149
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