Add support for pre-loading app native libraries - #713
Conversation
* Libraries are listed one-per-line in 'ld_preload.txt' file bundled in
Android assets
* Pre-loading of the libraries occurs before libmonodroid.so is loaded
* The primary use case here is to load a native crash manager (e.g., a
custom-built libBreakpad.so) which can install its signal handlers (via
ELF SHT_INIT_ARRAY ctors) below the Mono signal handlers
|
Hello! I'm the build bot for the Mono project. I need approval from a Mono team member to build this pull request. A team member should reply with "approve" to approve a build of this pull request, "whitelist" to whitelist this and all future pull requests from this contributor, or "build" to explicitly request a build, even if one has already been done. Additional trigger words are available here. Contributors can ignore this message. |
|
@mauiaaron, It will cover your contributions to all .NET Foundation-managed open source projects. |
|
@mauiaaron, thanks for signing the contribution license agreement. We will now validate the agreement and then the pull request. |
|
I don't like this PR. Which isn't to say that it can't be salvaged; I'm just uncertain about the intended use case.
This is not discoverable. Certainly, documentation can be written and read, but historically developers don't read (much) documentation. I thus fear it won't be used. Assuming it should be used.
This implicitly assumes that the only way to preload libraries is through this mechanism, which isn't the case. There are two other ways to preload libraries:
Finally, this PR requires that the native library export a This is not necessarily the case for all libraries which would need to be involved in preloading.
Assuming your Additionally, this is (more or less) exactly the scenario that // No idea what this declaration *should* be...
[DllImport ("Breakpad")]
static extern void Java_net_hockeyapp_android_NativeCrashManager_nativeSetUpBreakpad(IntPtr jnienv, IntPtr klass);
public static void InitBreakpad()
{
Mono.Runtime.RemoveSignalHandlers ();
Java_net_hockeyapp_android_NativeCrashManager_nativeSetUpBreakpad (JNIEnv.Handle, IntPtr.Zero);
Mono.Runtime.InstallSignalHandlers ();
}(Here I'm assuming that |
|
Hi @jonpryor, thank you for your careful review. Yes currently we are relying on ELF SHT_INIT_ARRAY ctors to perform initialization before Mono. Apologies, I was not aware of the "Certainly, documentation can be written and read, but historically developers don't read (much) documentation" ... Yes, I think I make this point perfectly with this PR ;) I will investigate the Mono signal handler API and report back. |
|
Suggested API works fine in debug and release modes, so withdrawing this PR. Thanks! |
|
Speaking of actual documentation on |
Libraries are listed one-per-line in 'ld_preload.txt' file bundled in Android assets
Pre-loading of the libraries occurs before libmonodroid.so is loaded
The primary use case here is to load a native crash manager (e.g., a custom-built libBreakpad.so) which can install its signal handlers (via ELF SHT_INIT_ARRAY ctors) below the Mono signal handlers