diff options
Diffstat (limited to 'scripts/crunch_win.sh')
| -rwxr-xr-x | scripts/crunch_win.sh | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/scripts/crunch_win.sh b/scripts/crunch_win.sh new file mode 100755 index 0000000..59d7889 --- /dev/null +++ b/scripts/crunch_win.sh @@ -0,0 +1,36 @@ +#!/bin/bash +set -e + +INPUT_EXE="build_win/demo64k.exe" +STRIPPED_EXE="build_win/demo64k_stripped.exe" +PACKED_EXE="build_win/demo64k_packed.exe" + +if [ ! -f "$INPUT_EXE" ]; then + echo "Error: $INPUT_EXE not found. Run scripts/build_win.sh first." + exit 1 +fi + +echo "Crunching $INPUT_EXE..." + +# 1. Strip debug symbols and sections +cp "$INPUT_EXE" "$STRIPPED_EXE" +x86_64-w64-mingw32-strip -s "$STRIPPED_EXE" +x86_64-w64-mingw32-strip --strip-unneeded "$STRIPPED_EXE" +x86_64-w64-mingw32-strip -R .comment -R .gnu.version "$STRIPPED_EXE" + +# 2. Pack with UPX +# --best: max compression +# --lzma: use lzma algorithm (usually smallest) +# --filter=...: filters for x86 code +cp "$STRIPPED_EXE" "$PACKED_EXE" +upx --best --lzma --overlay=strip "$PACKED_EXE" + +echo "------------------------------------------------" +echo "Size Report:" +ls -lh "$INPUT_EXE" +ls -lh "$STRIPPED_EXE" +ls -lh "$PACKED_EXE" +echo "------------------------------------------------" +echo "Top 10 Largest Symbols (from unstripped):" +x86_64-w64-mingw32-nm --print-size --size-sort --radix=d "$INPUT_EXE" | tail -n 10 +echo "------------------------------------------------" |
