"""Check arm64 ELF LOAD segments in an AAR/APK for 16 KiB alignment.""" import struct import sys import zipfile from pathlib import Path path = Path(sys.argv[1]) if len(sys.argv) > 1 else Path(__file__).resolve().parents[1] / "app/libs/sherpa-onnx-2.0.1.aar" failed = False count = 0 with zipfile.ZipFile(path) as archive: for name in archive.namelist(): if "arm64-v8a/" not in name or not name.endswith(".so"): continue count += 1 data = archive.read(name) if data[:6] != b"\x7fELF\x02\x01": raise SystemExit(f"Unsupported ELF: {name}") start = struct.unpack_from("= 16384 and p[2] % 16384 == p[3] % 16384 for p in loads) print(f"{'PASS' if valid else 'FAIL'} {name}") failed |= not valid if not count: raise SystemExit("No arm64 native libraries found") raise SystemExit(1 if failed else 0)