Skip to content

Native library fails to load at runtime on Android devices with 16KB page size, despite the ELF file itself being correctly aligned to 16KB boundaries. #10545

@AnkitPatel27

Description

@AnkitPatel27

Description

I checked my .so file ELF alignment based on test given by Android https://source.android.com/docs/core/architecture/16kb-page-size/16kb

I also unzipped the apk generated and looked into the .so file it and performed those test for zip alignment and and the libraries ELF alignment both were good.

~/bin/check_elf_alignment.sh library.so 

=== ELF alignment ===
library.so: \e[32mALIGNED\e[0m (2**14)

so why do i keep getting the issue
Shared library 'library' not loaded, p/invoke 'OpenSslFMInitialize' may fail /data/app/~~9Yy2yAyLjKLdUrFql0KS8A==/maui.chat-FpmeCHqtkTB_Xozk9GSAKQ==/split_config.arm64_v8a.apk!/lib/arm64-v8a/library.so" program alignment (4096) cannot be smaller than system page size (16384)

I am using this to load my DLL's
[DllImport(DllName, EntryPoint = "OpenSslFMInitialize", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]

Steps to Reproduce

No response

Link to public reproduction project repository

No response

Version with bug

9.0.110 SR12

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

No response

Affected platforms

Android

Affected platform versions

Testing on Android phone with 16KB enabled

Did you find any workaround?

No response

Relevant log output

Metadata

Metadata

Assignees

Labels

need-attentionA xamarin-android contributor needs to review

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions