This commit is contained in:
Executable
+91
@@ -0,0 +1,91 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
readonly REQUIRED_PAGE_SIZE=$((16 * 1024))
|
||||
|
||||
usage() {
|
||||
echo "Usage: $0 path/to/app-pixel10-release.apk" >&2
|
||||
}
|
||||
|
||||
if [[ $# -ne 1 ]]; then
|
||||
usage
|
||||
exit 2
|
||||
fi
|
||||
|
||||
apk="$1"
|
||||
if [[ ! -f "$apk" ]]; then
|
||||
echo "APK not found: $apk" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for command_name in unzip readelf; do
|
||||
if ! command -v "$command_name" >/dev/null 2>&1; then
|
||||
echo "Required command not found: $command_name" >&2
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
native_entries="$(unzip -Z1 "$apk" | sed -n '/^lib\/.*\.so$/p')"
|
||||
if [[ -z "$native_entries" ]]; then
|
||||
echo "No native libraries found in $apk" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
unexpected_abis=()
|
||||
while IFS= read -r entry; do
|
||||
if [[ "$entry" != lib/arm64-v8a/* ]]; then
|
||||
unexpected_abis+=("$entry")
|
||||
fi
|
||||
done <<< "$native_entries"
|
||||
|
||||
if [[ ${#unexpected_abis[@]} -gt 0 ]]; then
|
||||
echo "Pixel 10 APK contains non-ARM64 native libraries:" >&2
|
||||
printf ' %s\n' "${unexpected_abis[@]}" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
temporary_root="${TMPDIR:-/tmp}"
|
||||
if [[ ! -d "$temporary_root" || ! -w "$temporary_root" ]]; then
|
||||
temporary_root="$PWD"
|
||||
fi
|
||||
temporary_directory="$(mktemp -d "$temporary_root/mrbweblibre-verify.XXXXXX")"
|
||||
trap 'rm -rf -- "$temporary_directory"' EXIT
|
||||
unzip -qq "$apk" 'lib/arm64-v8a/*.so' -d "$temporary_directory"
|
||||
|
||||
failures=0
|
||||
checked=0
|
||||
native_library_list="$temporary_directory/native-libraries.list"
|
||||
find "$temporary_directory/lib/arm64-v8a" -type f -name '*.so' -print0 > "$native_library_list"
|
||||
while IFS= read -r -d '' library; do
|
||||
checked=$((checked + 1))
|
||||
machine="$(readelf -hW "$library" | sed -n 's/^[[:space:]]*Machine:[[:space:]]*//p')"
|
||||
if [[ "$machine" != "AArch64" ]]; then
|
||||
echo "Architecture failure: ${library#"$temporary_directory"/} is $machine, expected AArch64" >&2
|
||||
failures=$((failures + 1))
|
||||
continue
|
||||
fi
|
||||
|
||||
load_alignments="$(readelf -lW "$library" | awk '$1 == "LOAD" { print $NF }')"
|
||||
|
||||
if [[ -z "$load_alignments" ]]; then
|
||||
echo "No ELF LOAD segments found: ${library#"$temporary_directory"/}" >&2
|
||||
failures=$((failures + 1))
|
||||
continue
|
||||
fi
|
||||
|
||||
while IFS= read -r alignment; do
|
||||
if (( alignment < REQUIRED_PAGE_SIZE )); then
|
||||
echo "16 KB alignment failure: ${library#"$temporary_directory"/} has LOAD alignment $alignment" >&2
|
||||
failures=$((failures + 1))
|
||||
break
|
||||
fi
|
||||
done <<< "$load_alignments"
|
||||
done < "$native_library_list"
|
||||
|
||||
if (( failures > 0 )); then
|
||||
echo "Pixel 10 compatibility verification failed ($failures issue(s))." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Pixel 10 APK verified: ARM64-only; $checked native libraries use 16 KB-compatible ELF alignment."
|
||||
Reference in New Issue
Block a user