import zipfile import struct import sys import os def check_so_alignment(aab_path): print(f"Checking AAB: {aab_path}") try: with zipfile.ZipFile(aab_path, 'r') as z: so_files = [f for f in z.namelist() if f.endswith('.so') and 'arm64-v8a' in f] if not so_files: print("No arm64-v8a .so files found in the AAB.") return print(f"Found {len(so_files)} arm64-v8a .so files.") issues = [] for so_name in so_files: with z.open(so_name) as f: data = f.read() # Check ELF magic if data[:4] != b'\x7fELF': print(f"Skipping {so_name}: Not an ELF file") continue # Check class (64-bit) if data[4] != 2: print(f"Skipping {so_name}: Not a 64-bit ELF") continue # Parse ELF Header (Elf64_Ehdr) # e_phoff is at offset 32 (0x20), 64-bit unsigned e_phoff = struct.unpack('") sys.exit(1) check_so_alignment(sys.argv[1])