dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.47k stars 4.76k forks source link

[Android] Mono should not probe any filesystem locations for shared libraries #37321

Open grendello opened 4 years ago

grendello commented 4 years ago

Mono performs a lot of location probing when trying to find a shared library managed code tries to p/invoke into. This is not necessary on Android which won't have any DSOs in any of the locations probed by Mono. There's also no pre-determined location where app shared libraries are, Xamarin.Android learns about the location(s) only when it's started - they are passed as application startup arguments (both filesystem locations and APK locations). Mono should simply always call the Xamarin.Android dlopen hook, except when it sees that the p/invoke library name matches one of the following:

libandroid.so
libc.so
libdl.so
libEGL.so
libGLESv1_CM.so
libGLESv2.so
libGLESv3.so
libjnigraphics.so
liblog.so
libmediandk.so
libm.so
libOpenMAXAL.so
libOpenSLES.so
libstdc++.so
libz.so

The list is taken from the Android NDK, by listing any of the platforms/android-API_LEVEL/arch-*/usr/lib directories and it names the only "blessed" shared libraries that are accessible to the application in /system. At the same time, Mono should not stat the files in /system if it sees any of the above names, but simply issue a dlopen + dlsym for the specified name.

/cc @CoffeeFlux

ghost commented 4 years ago

Tagging subscribers to this area: @CoffeeFlux Notify danmosemsft if you want to be subscribed.

SamMonoRT commented 3 years ago

Nice to have, but not required - Moving to 7.0.0

fanyang-mono commented 1 year ago

Moving to 9.0.0