Google warning: .so files must align to 16KB – Release build config & performance issue

Hello everyone,
When building Collabora Office for Android, I noticed Google Play now requires all native .so libraries to use 16 KB (0x4000) page alignment instead of the default 4 KB.

  • I tried patching .so files afterwards with objcopy, but alignment in ELF Program Headers remains at 0x1000.

  • From my understanding, this should be configured at link time with flags like:

    -Wl,-z,max-page-size=16384 -Wl,-z,common-page-size=16384
    
    

Additionally, in Release builds, I observe significant performance issues:

  • Opening large .doc documents is very slow, sometimes takes very long before the first page is rendered.

  • Debug builds are already heavy, but I would like to know if there are recommended release linker/compiler flags (e.g. LTO, stripping symbols, optimization) that should be applied to make runtime smoother.


:backhand_index_pointing_right: My questions:

  1. What is the recommended way to configure the Android release build of Collabora Office so that all .so libraries comply with Google’s 16 KB requirement?

  2. Are there best practices for release build optimization (flags, configs) to improve document rendering performance on Android?

  3. Has anyone else faced the issue where .doc files take very long to render the first page, and how did you solve it?

Thanks in advance for any guidance!

  • You’ll need to relink the native libraries with a linker that supports 16 KB ELF page alignment — using objcopy after the fact generally won’t change the p_align values in the program headers (Android Developers).
  • Use the LLD/Clang linker and pass the ELF page-size options at link time, for example: -Wl,-z,max-page-size=16384 -Wl,-z,common-page-size=16384. Then verify with readelf -l libfoo.so to check the p_align values (Fuchsia source).

I’m not sure how your build is currently configured, but I found this discussion on the Collabora forum where other users have tried various flags that might help as well.