summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2024-05-02 01:27:31 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2024-05-02 01:27:31 +0000
commitb81b3c5afd9256dd5c2d22418e8d96e15b10cf77 (patch)
treef5b53d90d0f4c02a76b82d2e62acac2f280db0cd
parentc044d9e09208f9cbeab94aec6a4037698c6760d5 (diff)
parentb6ef25a6815f09ae54c95858aee5d7042219d3d0 (diff)
downloadextras-sdk-release.tar.gz
Merge "Snap for 11790536 from 14be9dd102f0128c2fce8068e8bd350d05e5e26e to sdk-release" into sdk-releasesdk-release
-rwxr-xr-xtools/check_elf_alignment.sh26
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 "====================="