diff --git a/psprecomp/android/apk_pack.py b/psprecomp/android/apk_pack.py index 43bd02b..5a389d4 100644 --- a/psprecomp/android/apk_pack.py +++ b/psprecomp/android/apk_pack.py @@ -91,6 +91,39 @@ def sign_apk_bytes(data, key): return entries + block + cd + bytes(eocd) +PAGE_16K = 16384 + + +def elf_load_align(path): + """The smallest p_align of the PT_LOAD segments of a 64-bit little-endian ELF, or None when the file is not one (a zip payload + shipped as lib*.so).""" + with open(path, "rb") as f: + h = f.read(64) + if len(h) < 64 or h[:4] != b"\x7fELF" or h[4] != 2 or h[5] != 1: + return None + phoff, = struct.unpack_from(" classes.dex diff --git a/psprecomp/docs/android.md b/psprecomp/docs/android.md index f984554..5a367ae 100644 --- a/psprecomp/docs/android.md +++ b/psprecomp/docs/android.md @@ -125,6 +125,9 @@ Not yet run: the GitHub workflow, and an update against a real release. See [installer.md](installer.md), "Android progress": the renderer talks OpenGL ES through `runtime/include/psp_gl.h`; the release ships the prebuilt Android core and libraries (SDL2, FreeType, FFmpeg decoders) built with NDK r27c, an unsigned APK skeleton (manifest + SDL's Java activity) and a pure-Python packer/signer (APK Signature Scheme v2, `android/apk_pack.py`, a public debug key), so the player's machine needs only the NDK compiler. +Every native library is linked for 16 KB pages (`ANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES`, i.e. `-z max-page-size=16384`; the on-device link +passes it to `ld.lld` directly), so the game loads on devices running a 16 KB-page kernel and debuggable builds show no "isn't 16 KB +compatible" dialog; `apk_pack.py` warns about any `lib/*.so` whose LOAD segments are aligned below 16 KB. ## Keeping the shader list complete diff --git a/psprecomp/games/dissidia/tools/android_build.py b/psprecomp/games/dissidia/tools/android_build.py index 6221ea5..7368133 100644 --- a/psprecomp/games/dissidia/tools/android_build.py +++ b/psprecomp/games/dissidia/tools/android_build.py @@ -131,7 +131,7 @@ def write_toolchain(adir, work): tc = os.path.join(bd, "toolchain.cmake") ndk = os.path.join(adir, "ndk").replace("\\", "/") with open(tc, "w") as f: - f.write('set(ANDROID_ABI %s)\nset(ANDROID_PLATFORM android-%d)\ninclude("%s/build/cmake/android.toolchain.cmake")\n' + f.write('set(ANDROID_ABI %s)\nset(ANDROID_PLATFORM android-%d)\nset(ANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES ON)\ninclude("%s/build/cmake/android.toolchain.cmake")\n' 'set(PSPRECOMP_DEPS_CMAKE "%s/deps/deps.cmake")\n' % (v["abi"], v["api"], ndk, adir.replace("\\", "/"))) return bd, tc