Commit 58295518 for openh264
commit 5829551822d052127bebe1d0e271c1e6f7f2c9cc
Author: Hashim Khan <sardarhashim30@gmail.com>
Date: Mon Sep 21 10:36:40 2026 +0500
Align Android shared libraries to 16 KB pages (#3997)
* Align Android shared libraries to 16 KB pages
* Set Android ELF common page size to 16 KB as well.
* Potential fix for pull request finding
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
* Align remaining Android libraries to 16 KB pages
---------
Co-authored-by: BenzhengZhang <140143892+BenzhengZhang@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: benzzhan <benzzhan@cisco.com>
diff --git a/build/platform-android-r18b.mk b/build/platform-android-r18b.mk
index 0c442dfa..19d56164 100644
--- a/build/platform-android-r18b.mk
+++ b/build/platform-android-r18b.mk
@@ -51,8 +51,8 @@ endif
CFLAGS += -isystem $(NDKROOT)/sysroot/usr/include -isystem $(NDKROOT)/sysroot/usr/include/$(TOOLCHAIN_NAME) -D__ANDROID_API__=$(NDKLEVEL)
CXXFLAGS += -fno-rtti -fno-exceptions
LDFLAGS += --sysroot=$(SYSROOT)
-SHLDFLAGS = -Wl,--no-undefined -Wl,-z,relro -Wl,-z,now -Wl,-soname,lib$(PROJECT_NAME).so
-UTSHLDFLAGS = -Wl,-soname,libut.so
+SHLDFLAGS = -Wl,--no-undefined -Wl,-z,relro -Wl,-z,now -Wl,-z,max-page-size=16384 -Wl,-z,common-page-size=16384 -Wl,-soname,lib$(PROJECT_NAME).so
+UTSHLDFLAGS = -Wl,-z,max-page-size=16384 -Wl,-z,common-page-size=16384 -Wl,-soname,libut.so
ifeq ($(NDK_TOOLCHAIN_VERSION), clang)
HOST_OS = $(shell uname -s | tr [A-Z] [a-z])
diff --git a/build/platform-android.mk b/build/platform-android.mk
index 88e41d9e..4a030ff8 100644
--- a/build/platform-android.mk
+++ b/build/platform-android.mk
@@ -45,8 +45,8 @@ endif
CFLAGS += -DANDROID_NDK -fpic -MMD -MP -fstack-protector-all
CXXFLAGS += -fno-rtti -fno-exceptions
-SHLDFLAGS = -Wl,--no-undefined -Wl,-z,relro -Wl,-z,now -Wl,-soname,lib$(PROJECT_NAME).so
-UTSHLDFLAGS = -Wl,-soname,libut.so
+SHLDFLAGS = -Wl,--no-undefined -Wl,-z,relro -Wl,-z,now -Wl,-z,max-page-size=16384 -Wl,-z,common-page-size=16384 -Wl,-soname,lib$(PROJECT_NAME).so
+UTSHLDFLAGS = -Wl,-z,max-page-size=16384 -Wl,-z,common-page-size=16384 -Wl,-soname,libut.so
ifeq ($(NDK_TOOLCHAIN_VERSION), clang)
LLVM_INSTALL_DIR = $(wildcard $(NDKROOT)/toolchains/llvm/prebuilt/*/bin)
diff --git a/codec/build/android/dec/jni/Application.mk b/codec/build/android/dec/jni/Application.mk
index 175295f4..0941d6f0 100644
--- a/codec/build/android/dec/jni/Application.mk
+++ b/codec/build/android/dec/jni/Application.mk
@@ -4,3 +4,4 @@ else
APP_STL := stlport_shared
endif
APP_PLATFORM := android-12
+APP_SUPPORT_FLEXIBLE_PAGE_SIZES := true
diff --git a/codec/build/android/dec/jni/welsdecdemo.mk b/codec/build/android/dec/jni/welsdecdemo.mk
index 8e667dc8..09e04bea 100644
--- a/codec/build/android/dec/jni/welsdecdemo.mk
+++ b/codec/build/android/dec/jni/welsdecdemo.mk
@@ -40,6 +40,7 @@ LOCAL_C_INCLUDES := \
# Compile Flags and Link Libraries
#
LOCAL_CFLAGS := -DANDROID_NDK
+LOCAL_LDFLAGS += -Wl,-z,max-page-size=16384 -Wl,-z,common-page-size=16384
LOCAL_LDLIBS := -llog
LOCAL_SHARED_LIBRARIES := wels
diff --git a/codec/build/android/enc/jni/Application.mk b/codec/build/android/enc/jni/Application.mk
index 175295f4..0941d6f0 100644
--- a/codec/build/android/enc/jni/Application.mk
+++ b/codec/build/android/enc/jni/Application.mk
@@ -4,3 +4,4 @@ else
APP_STL := stlport_shared
endif
APP_PLATFORM := android-12
+APP_SUPPORT_FLEXIBLE_PAGE_SIZES := true
diff --git a/codec/build/android/enc/jni/welsencdemo.mk b/codec/build/android/enc/jni/welsencdemo.mk
index 14d01e82..df34b634 100644
--- a/codec/build/android/enc/jni/welsencdemo.mk
+++ b/codec/build/android/enc/jni/welsencdemo.mk
@@ -44,6 +44,7 @@ LOCAL_C_INCLUDES := \
# Compile Flags and Link Libraries
#
LOCAL_CFLAGS := -DANDROID_NDK
+LOCAL_LDFLAGS += -Wl,-z,max-page-size=16384 -Wl,-z,common-page-size=16384
LOCAL_LDLIBS := -llog
LOCAL_SHARED_LIBRARIES := wels
diff --git a/meson.build b/meson.build
index a0dfd219..6cb55e3f 100644
--- a/meson.build
+++ b/meson.build
@@ -143,6 +143,10 @@ else
error('FIXME: Unhandled system @0@'.format(system))
endif
+if system == 'android'
+ add_project_link_arguments('-Wl,-z,max-page-size=16384', '-Wl,-z,common-page-size=16384', language: ['c', 'cpp'])
+endif
+
use_asm_gen = false
if cpu_family in ['x86', 'x86_64']
nasm = find_program('nasm')
diff --git a/test/build/android/jni/Android.mk b/test/build/android/jni/Android.mk
index e354a360..a6346dc5 100644
--- a/test/build/android/jni/Android.mk
+++ b/test/build/android/jni/Android.mk
@@ -31,6 +31,7 @@ LOCAL_C_INCLUDES := \
# Compile Flags and Link Libraries
#
LOCAL_CFLAGS := -DANDROID_NDK
+LOCAL_LDFLAGS += -Wl,-z,max-page-size=16384 -Wl,-z,common-page-size=16384
LOCAL_LDLIBS := -llog
LOCAL_SHARED_LIBRARIES := libUT
diff --git a/test/build/android/jni/Application.mk b/test/build/android/jni/Application.mk
index 175295f4..0941d6f0 100644
--- a/test/build/android/jni/Application.mk
+++ b/test/build/android/jni/Application.mk
@@ -4,3 +4,4 @@ else
APP_STL := stlport_shared
endif
APP_PLATFORM := android-12
+APP_SUPPORT_FLEXIBLE_PAGE_SIZES := true