From 33dfba1d9c06723c4decf2b38705c3fa7ef4f198 Mon Sep 17 00:00:00 2001 From: David Srbecky Date: Sat, 20 Mar 2021 14:46:15 +0000 Subject: [PATCH] Revert "[strip.sh] Move remaining GNU binutils usage to llvm binutils" This reverts commit ad50ce83497c7d25a5167ea6bdef1f0290b99f58. Bug: 183237575 Reason for revert: Breaks stack unwinding Change-Id: I256dc77525687fb3e670355587b1eac72158b274 --- cc/builder.go | 2 +- scripts/strip.sh | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/cc/builder.go b/cc/builder.go index c70cd9b92..9cd78d59a 100644 --- a/cc/builder.go +++ b/cc/builder.go @@ -132,7 +132,7 @@ var ( blueprint.RuleParams{ Depfile: "${out}.d", Deps: blueprint.DepsGCC, - Command: "XZ=$xzCmd CLANG_BIN=${config.ClangBin} $stripPath ${args} -i ${in} -o ${out} -d ${out}.d", + Command: "CROSS_COMPILE=$crossCompile XZ=$xzCmd CLANG_BIN=${config.ClangBin} $stripPath ${args} -i ${in} -o ${out} -d ${out}.d", CommandDeps: []string{"$stripPath", "$xzCmd"}, Pool: darwinStripPool, }, diff --git a/scripts/strip.sh b/scripts/strip.sh index b3606195f..5b7a6da7e 100755 --- a/scripts/strip.sh +++ b/scripts/strip.sh @@ -18,6 +18,7 @@ # Inputs: # Environment: # CLANG_BIN: path to the clang bin directory +# CROSS_COMPILE: prefix added to readelf, objcopy tools # XZ: path to the xz binary # Arguments: # -i ${file}: input file (required) @@ -68,7 +69,7 @@ do_strip_keep_symbol_list() { KEEP_SYMBOLS="--strip-unneeded-symbol=* --keep-symbols=" KEEP_SYMBOLS+="${outfile}.symbolList" - "${CLANG_BIN}/llvm-objcopy" -w "${infile}" "${outfile}.tmp" ${KEEP_SYMBOLS} + "${CROSS_COMPILE}objcopy" -w "${infile}" "${outfile}.tmp" ${KEEP_SYMBOLS} } do_strip_keep_mini_debug_info() { @@ -80,14 +81,14 @@ do_strip_keep_mini_debug_info() { # Current prebult llvm-objcopy does not support --only-keep-debug flag, # and cannot process object files that are produced with the flag. Use # GNU objcopy instead for now. (b/141010852) - "${CLANG_BIN}/llvm-objcopy" --only-keep-debug "${infile}" "${outfile}.debug" + "${CROSS_COMPILE}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" "${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" echo >> "${outfile}.keep_symbols" # Ensure that the keep_symbols file is not empty. - "${CLANG_BIN}/llvm-objcopy" --rename-section .debug_frame=saved_debug_frame "${outfile}.debug" "${outfile}.mini_debuginfo" - "${CLANG_BIN}/llvm-objcopy" -S --remove-section .gdb_index --remove-section .comment --keep-symbols="${outfile}.keep_symbols" "${outfile}.mini_debuginfo" - "${CLANG_BIN}/llvm-objcopy" --rename-section saved_debug_frame=.debug_frame "${outfile}.mini_debuginfo" + "${CROSS_COMPILE}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" + "${CROSS_COMPILE}objcopy" --rename-section saved_debug_frame=.debug_frame "${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" @@ -195,6 +196,7 @@ mv "${outfile}.tmp" "${outfile}" cat < "${depsfile}" ${outfile}: \ ${infile} \ + ${CROSS_COMPILE}objcopy \ ${CLANG_BIN}/llvm-nm \ ${CLANG_BIN}/llvm-objcopy \ ${CLANG_BIN}/llvm-readelf \