From b474fc0ad6542911fb1895bc715f8e88bdb7794f Mon Sep 17 00:00:00 2001 From: David Srbecky Date: Sat, 20 Mar 2021 12:47:38 +0000 Subject: [PATCH] Remove .rustc ELF section from mini-debug-info. The section is stripped from binaries (but preserved in /symbols). However, is it also unintentionally copied into the minidebuginfo compressed section, which is included in the final shipped binary. (This does not affect symtab symbols, which are handled as usual) Removing it from mini-debug-info shrinks some rust binaries by up to 10x, saving >10MB on the system partition overall (AOSP). Test: extract minidebuginfo and check it manually with readelf Change-Id: I462d81455626bb2b5244e1bf3d5f8b71646f3401 --- scripts/strip.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/strip.sh b/scripts/strip.sh index 5b7a6da7e..43e6cbf39 100755 --- a/scripts/strip.sh +++ b/scripts/strip.sh @@ -87,7 +87,7 @@ do_strip_keep_mini_debug_info() { comm -13 "${outfile}.dynsyms" "${outfile}.funcsyms" > "${outfile}.keep_symbols" 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" - "${CROSS_COMPILE}objcopy" -S --remove-section .gdb_index --remove-section .comment --keep-symbols="${outfile}.keep_symbols" "${outfile}.mini_debuginfo" + "${CROSS_COMPILE}objcopy" -S --remove-section .gdb_index --remove-section .comment --remove-section .rustc --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"