diff options
-rw-r--r-- | build/cmake/android-legacy.toolchain.cmake | 2 | ||||
-rw-r--r-- | build/cmake/flags.cmake | 2 | ||||
-rw-r--r-- | build/core/build-binary.mk | 2 | ||||
-rw-r--r-- | tests/build/alignment_compat/test.py | 12 |
4 files changed, 12 insertions, 6 deletions
diff --git a/build/cmake/android-legacy.toolchain.cmake b/build/cmake/android-legacy.toolchain.cmake index 610024b4d..252a199c1 100644 --- a/build/cmake/android-legacy.toolchain.cmake +++ b/build/cmake/android-legacy.toolchain.cmake @@ -459,7 +459,7 @@ list(APPEND ANDROID_COMPILER_FLAGS if(ANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES) list(APPEND ANDROID_COMPILER_FLAGS -D__BIONIC_NO_PAGE_SIZE_MACRO) - if(ANDROID_ABI STREQUAL arm64-v8a) + if(ANDROID_ABI STREQUAL arm64-v8a OR ANDROID_ABI STREQUAL x86_64) list(APPEND ANDROID_LINKER_FLAGS -Wl,-z,max-page-size=16384) endif() endif() diff --git a/build/cmake/flags.cmake b/build/cmake/flags.cmake index f1f4eb977..11acc040a 100644 --- a/build/cmake/flags.cmake +++ b/build/cmake/flags.cmake @@ -32,7 +32,7 @@ string(APPEND _ANDROID_NDK_INIT_CFLAGS if(ANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES) string(APPEND _ANDROID_NDK_INIT_CFLAGS " -D__BIONIC_NO_PAGE_SIZE_MACRO") - if(ANDROID_ABI STREQUAL arm64-v8a) + if(ANDROID_ABI STREQUAL arm64-v8a OR ANDROID_ABI STREQUAL x86_64) string(APPEND _ANDROID_NDK_INIT_LDFLAGS " -Wl,-z,max-page-size=16384") endif() endif() diff --git a/build/core/build-binary.mk b/build/core/build-binary.mk index a09ef5ccf..7940c66bd 100644 --- a/build/core/build-binary.mk +++ b/build/core/build-binary.mk @@ -134,7 +134,7 @@ LOCAL_CFLAGS := -DANDROID $(LOCAL_CFLAGS) ifeq ($(APP_SUPPORT_FLEXIBLE_PAGE_SIZES),true) LOCAL_CFLAGS += -D__BIONIC_NO_PAGE_SIZE_MACRO - ifeq ($(APP_ABI),arm64-v8a) + ifneq (,$(filter $(APP_ABI),arm64-v8a x86_64)) LOCAL_LDFLAGS += -Wl,-z,max-page-size=16384 endif endif diff --git a/tests/build/alignment_compat/test.py b/tests/build/alignment_compat/test.py index 46f2f6619..1c7633e5b 100644 --- a/tests/build/alignment_compat/test.py +++ b/tests/build/alignment_compat/test.py @@ -61,8 +61,8 @@ def verify_load_section_alignment( if alignment != expected_alignment: return ( False, - f"{path.resolve()}: LOAD section at {offset:x} has incorrect alignment {alignment:x}. " - f"Expected {expected_alignment:x}", + f"{path.resolve()}: LOAD section at {offset:#x} has incorrect " + f"alignment {alignment:#x}. Expected {expected_alignment:#x}", ) return True, None @@ -95,8 +95,14 @@ def run_test(ndk_path: str, config: BuildConfiguration) -> tuple[bool, str | Non ndk_build_builder.build() except CalledProcessError as ex: return False, f"Build failed:\n{ex.stdout}" + + if config.abi in (Abi("arm64-v8a"), Abi("x86_64")): + expected_alignment = 16 * 1024 + else: + expected_alignment = 4 * 1024 + return verify_load_section_alignment_each_file( [cmake_builder.out_dir / "libfoo.so", ndk_build_builder.out_dir / "libfoo.so"], Path(ndk_path), - expected_alignment=16 * 1024 if config.abi == Abi("arm64-v8a") else 4 * 1024, + expected_alignment, ) |