Merge "[strip.sh] Move remaining GNU binutils usage to llvm binutils" am: 00d54280d0
am: dd3494b8e4
am: 55163399f5
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1235781 Change-Id: I04470e88b6848c10137368d6b8d7d91c99f1fd01
This commit is contained in:
commit
d28df8630d
|
@ -132,7 +132,7 @@ var (
|
||||||
blueprint.RuleParams{
|
blueprint.RuleParams{
|
||||||
Depfile: "${out}.d",
|
Depfile: "${out}.d",
|
||||||
Deps: blueprint.DepsGCC,
|
Deps: blueprint.DepsGCC,
|
||||||
Command: "CROSS_COMPILE=$crossCompile XZ=$xzCmd CLANG_BIN=${config.ClangBin} $stripPath ${args} -i ${in} -o ${out} -d ${out}.d",
|
Command: "XZ=$xzCmd CLANG_BIN=${config.ClangBin} $stripPath ${args} -i ${in} -o ${out} -d ${out}.d",
|
||||||
CommandDeps: []string{"$stripPath", "$xzCmd"},
|
CommandDeps: []string{"$stripPath", "$xzCmd"},
|
||||||
Pool: darwinStripPool,
|
Pool: darwinStripPool,
|
||||||
},
|
},
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
# Inputs:
|
# Inputs:
|
||||||
# Environment:
|
# Environment:
|
||||||
# CLANG_BIN: path to the clang bin directory
|
# CLANG_BIN: path to the clang bin directory
|
||||||
# CROSS_COMPILE: prefix added to readelf, objcopy tools
|
|
||||||
# XZ: path to the xz binary
|
# XZ: path to the xz binary
|
||||||
# Arguments:
|
# Arguments:
|
||||||
# -i ${file}: input file (required)
|
# -i ${file}: input file (required)
|
||||||
|
@ -69,7 +68,7 @@ do_strip_keep_symbol_list() {
|
||||||
|
|
||||||
KEEP_SYMBOLS="--strip-unneeded-symbol=* --keep-symbols="
|
KEEP_SYMBOLS="--strip-unneeded-symbol=* --keep-symbols="
|
||||||
KEEP_SYMBOLS+="${outfile}.symbolList"
|
KEEP_SYMBOLS+="${outfile}.symbolList"
|
||||||
"${CROSS_COMPILE}objcopy" -w "${infile}" "${outfile}.tmp" ${KEEP_SYMBOLS}
|
"${CLANG_BIN}/llvm-objcopy" -w "${infile}" "${outfile}.tmp" ${KEEP_SYMBOLS}
|
||||||
}
|
}
|
||||||
|
|
||||||
do_strip_keep_mini_debug_info() {
|
do_strip_keep_mini_debug_info() {
|
||||||
|
@ -81,14 +80,14 @@ do_strip_keep_mini_debug_info() {
|
||||||
# Current prebult llvm-objcopy does not support --only-keep-debug flag,
|
# Current prebult llvm-objcopy does not support --only-keep-debug flag,
|
||||||
# and cannot process object files that are produced with the flag. Use
|
# and cannot process object files that are produced with the flag. Use
|
||||||
# GNU objcopy instead for now. (b/141010852)
|
# GNU objcopy instead for now. (b/141010852)
|
||||||
"${CROSS_COMPILE}objcopy" --only-keep-debug "${infile}" "${outfile}.debug"
|
"${CLANG_BIN}/llvm-objcopy" --only-keep-debug "${infile}" "${outfile}.debug"
|
||||||
"${CLANG_BIN}/llvm-nm" -D "${infile}" --format=posix --defined-only 2> /dev/null | awk '{ print $1 }' | sort >"${outfile}.dynsyms"
|
"${CLANG_BIN}/llvm-nm" -D "${infile}" --format=posix --defined-only 2> /dev/null | awk '{ print $1 }' | sort >"${outfile}.dynsyms"
|
||||||
"${CLANG_BIN}/llvm-nm" "${infile}" --format=posix --defined-only | awk '{ if ($2 == "T" || $2 == "t" || $2 == "D") print $1 }' | sort > "${outfile}.funcsyms"
|
"${CLANG_BIN}/llvm-nm" "${infile}" --format=posix --defined-only | awk '{ if ($2 == "T" || $2 == "t" || $2 == "D") print $1 }' | sort > "${outfile}.funcsyms"
|
||||||
comm -13 "${outfile}.dynsyms" "${outfile}.funcsyms" > "${outfile}.keep_symbols"
|
comm -13 "${outfile}.dynsyms" "${outfile}.funcsyms" > "${outfile}.keep_symbols"
|
||||||
echo >> "${outfile}.keep_symbols" # Ensure that the keep_symbols file is not empty.
|
echo >> "${outfile}.keep_symbols" # Ensure that the keep_symbols file is not empty.
|
||||||
"${CROSS_COMPILE}objcopy" --rename-section .debug_frame=saved_debug_frame "${outfile}.debug" "${outfile}.mini_debuginfo"
|
"${CLANG_BIN}/llvm-objcopy" --rename-section .debug_frame=saved_debug_frame "${outfile}.debug" "${outfile}.mini_debuginfo"
|
||||||
"${CROSS_COMPILE}objcopy" -S --remove-section .gdb_index --remove-section .comment --keep-symbols="${outfile}.keep_symbols" "${outfile}.mini_debuginfo"
|
"${CLANG_BIN}/llvm-objcopy" -S --remove-section .gdb_index --remove-section .comment --keep-symbols="${outfile}.keep_symbols" "${outfile}.mini_debuginfo"
|
||||||
"${CROSS_COMPILE}objcopy" --rename-section saved_debug_frame=.debug_frame "${outfile}.mini_debuginfo"
|
"${CLANG_BIN}/llvm-objcopy" --rename-section saved_debug_frame=.debug_frame "${outfile}.mini_debuginfo"
|
||||||
"${XZ}" --block-size=64k --threads=0 "${outfile}.mini_debuginfo"
|
"${XZ}" --block-size=64k --threads=0 "${outfile}.mini_debuginfo"
|
||||||
|
|
||||||
"${CLANG_BIN}/llvm-objcopy" --add-section .gnu_debugdata="${outfile}.mini_debuginfo.xz" "${outfile}.tmp"
|
"${CLANG_BIN}/llvm-objcopy" --add-section .gnu_debugdata="${outfile}.mini_debuginfo.xz" "${outfile}.tmp"
|
||||||
|
@ -196,7 +195,6 @@ mv "${outfile}.tmp" "${outfile}"
|
||||||
cat <<EOF > "${depsfile}"
|
cat <<EOF > "${depsfile}"
|
||||||
${outfile}: \
|
${outfile}: \
|
||||||
${infile} \
|
${infile} \
|
||||||
${CROSS_COMPILE}objcopy \
|
|
||||||
${CLANG_BIN}/llvm-nm \
|
${CLANG_BIN}/llvm-nm \
|
||||||
${CLANG_BIN}/llvm-objcopy \
|
${CLANG_BIN}/llvm-objcopy \
|
||||||
${CLANG_BIN}/llvm-readelf \
|
${CLANG_BIN}/llvm-readelf \
|
||||||
|
|
Loading…
Reference in New Issue