diff options
author | Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> | 2024-05-01 20:33:57 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2024-05-01 20:33:57 +0000 |
commit | 14be9dd102f0128c2fce8068e8bd350d05e5e26e (patch) | |
tree | f5b53d90d0f4c02a76b82d2e62acac2f280db0cd | |
parent | 10bee1bdd695ae891e0960adb704e55ecb3e6965 (diff) | |
parent | 0f8316892f57713ab5f7970aaeb74d386b0191de (diff) | |
download | extras-main.tar.gz |
-rwxr-xr-x | tools/check_elf_alignment.sh | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tools/check_elf_alignment.sh b/tools/check_elf_alignment.sh index da1f0b3f..ba82eb7a 100755 --- a/tools/check_elf_alignment.sh +++ b/tools/check_elf_alignment.sh @@ -42,6 +42,19 @@ fi if [[ ${dir} == *.apk ]]; then trap 'cleanup_trap' EXIT + + if { zipalign --help 2>&1 | grep -q "\-P <pagesize_kb>"; }; then + echo "=== APK zip-alignment ===" + zipalign -v -c -P 16 4 ${dir} | egrep 'lib/arm64-v8a|lib/x86_64|Verification' + echo "=========================" + else + echo "NOTICE: Zip alignment check requires build-tools version 35.0.0-rc3 or higher." + echo " You can install the latest build-tools by running the below command" + echo " and updating your \$PATH:" + echo + echo " sdkmanager \"build-tools;35.0.0-rc3\"" + fi + dir_filename=$(basename ${dir}) tmp=$(mktemp -d -t ${dir_filename%.apk}_out_XXXXX) unzip ${dir} lib/arm64-v8a/* lib/x86_64/* -d ${tmp} >/dev/null 2>&1 @@ -52,6 +65,11 @@ RED="\e[31m" GREEN="\e[32m" ENDCOLOR="\e[0m" +unaligned_libs=() + +echo +echo "=== ELF alignment ===" + matches="$(find ${dir} -name "*.so" -type f)" IFS=$'\n' for match in $matches; do @@ -60,5 +78,13 @@ for match in $matches; do echo -e "${match}: ${GREEN}ALIGNED${ENDCOLOR} ($res)" else echo -e "${match}: ${RED}UNALIGNED${ENDCOLOR} ($res)" + unaligned_libs+=(${match}) fi done + +if [ ${#unaligned_libs[@]} -gt 0 ]; then + echo -e "${RED}Found ${#unaligned_libs[@]} unaligned libs${ENDCOLOR}" +elif [ -n "${dir_filename}" ]; then + echo -e "ELF Verification Successful" +fi +echo "=====================" |