@@ -87,8 +87,6 @@ MonoCoreRuntimeProperties MonodroidRuntime::monovm_core_properties = {
8787 .pinvoke_override = &MonodroidRuntime::monodroid_pinvoke_override
8888};
8989
90- std::mutex MonodroidRuntime::dso_handle_write_lock;
91-
9290void
9391MonodroidRuntime::thread_start ([[maybe_unused]] MonoProfiler *prof, [[maybe_unused]] uintptr_t tid)
9492{
@@ -1003,173 +1001,6 @@ setup_gc_logging (void)
10031001}
10041002#endif
10051003
1006- force_inline unsigned int
1007- MonodroidRuntime::convert_dl_flags (int flags)
1008- {
1009- unsigned int lflags = (flags & static_cast <int > (MONO_DL_LOCAL))
1010- ? JAVA_INTEROP_LIB_LOAD_LOCALLY
1011- : JAVA_INTEROP_LIB_LOAD_GLOBALLY;
1012- return lflags;
1013- }
1014-
1015- force_inline DSOCacheEntry*
1016- MonodroidRuntime::find_dso_cache_entry (hash_t hash) noexcept
1017- {
1018- auto equal = [](DSOCacheEntry const & entry, hash_t key) -> bool { return entry.hash == key; };
1019- auto less_than = [](DSOCacheEntry const & entry, hash_t key) -> bool { return entry.hash < key; };
1020- ssize_t idx = Search::binary_search<DSOCacheEntry, equal, less_than> (hash, dso_cache, application_config.number_of_dso_cache_entries );
1021- if (idx >= 0 ) {
1022- return &dso_cache[idx];
1023- }
1024-
1025- return nullptr ;
1026- }
1027-
1028- force_inline void *
1029- MonodroidRuntime::monodroid_dlopen_log_and_return (void *handle, char **err, const char *full_name, bool free_memory, [[maybe_unused]] bool need_api_init)
1030- {
1031- if (handle == nullptr && err != nullptr ) {
1032- const char *load_error = dlerror ();
1033- if (load_error == nullptr ) {
1034- load_error = " Unknown error" ;
1035- }
1036- *err = Util::monodroid_strdup_printf (" Could not load library '%s'. %s" , full_name, load_error);
1037- }
1038-
1039- if (free_memory) {
1040- delete[] full_name;
1041- }
1042-
1043- return handle;
1044- }
1045-
1046- force_inline void *
1047- MonodroidRuntime::monodroid_dlopen_ignore_component_or_load ([[maybe_unused]] hash_t name_hash, const char *name, int flags, char **err) noexcept
1048- {
1049- if (MonodroidState::is_startup_in_progress ()) {
1050- auto ignore_component = [&](const char *label, MonoComponent component) -> bool {
1051- if ((application_config.mono_components_mask & component) != component) {
1052- log_info (LOG_ASSEMBLY, " Mono '%s' component requested but not packaged, ignoring" , label);
1053- return true ;
1054- }
1055-
1056- return false ;
1057- };
1058-
1059- switch (name_hash) {
1060- case mono_component_debugger_hash:
1061- if (ignore_component (" Debugger" , MonoComponent::Debugger)) {
1062- return nullptr ;
1063- }
1064- break ;
1065-
1066- case mono_component_hot_reload_hash:
1067- if (ignore_component (" Hot Reload" , MonoComponent::HotReload)) {
1068- return nullptr ;
1069- }
1070- break ;
1071-
1072- case mono_component_diagnostics_tracing_hash:
1073- if (ignore_component (" Diagnostics Tracing" , MonoComponent::Tracing)) {
1074- return nullptr ;
1075- }
1076- break ;
1077- }
1078- }
1079-
1080- unsigned int dl_flags = monodroidRuntime.convert_dl_flags (flags);
1081- void * handle = AndroidSystem::load_dso_from_any_directories (name, dl_flags);
1082- if (handle != nullptr ) {
1083- return monodroid_dlopen_log_and_return (handle, err, name, false /* name_needs_free */ );
1084- }
1085-
1086- handle = AndroidSystem::load_dso (name, dl_flags, false /* skip_existing_check */ );
1087- return monodroid_dlopen_log_and_return (handle, err, name, false /* name_needs_free */ );
1088- }
1089-
1090- force_inline void *
1091- MonodroidRuntime::monodroid_dlopen (const char *name, int flags, char **err) noexcept
1092- {
1093- hash_t name_hash = xxhash::hash (name, strlen (name));
1094- log_debug (LOG_ASSEMBLY, " monodroid_dlopen: hash for name '%s' is 0x%zx" , name, name_hash);
1095- DSOCacheEntry *dso = find_dso_cache_entry (name_hash);
1096- log_debug (LOG_ASSEMBLY, " monodroid_dlopen: hash match %sfound, DSO name is '%s'" , dso == nullptr ? " not " : " " , dso == nullptr ? " <unknown>" : dso->name );
1097-
1098- if (dso == nullptr ) {
1099- // DSO not known at build time, try to load it
1100- return monodroid_dlopen_ignore_component_or_load (name_hash, name, flags, err);
1101- } else if (dso->handle != nullptr ) {
1102- return monodroid_dlopen_log_and_return (dso->handle , err, dso->name , false /* name_needs_free */ );
1103- }
1104-
1105- if (dso->ignore ) {
1106- log_info (LOG_ASSEMBLY, " Request to load '%s' ignored, it is known not to exist" , dso->name );
1107- return nullptr ;
1108- }
1109-
1110- StartupAwareLock lock (dso_handle_write_lock);
1111- #if defined (RELEASE)
1112- if (AndroidSystem::is_embedded_dso_mode_enabled ()) {
1113- DSOApkEntry *apk_entry = dso_apk_entries;
1114- for (size_t i = 0 ; i < application_config.number_of_shared_libraries ; i++) {
1115- if (apk_entry->name_hash != dso->real_name_hash ) {
1116- apk_entry++;
1117- continue ;
1118- }
1119-
1120- android_dlextinfo dli;
1121- dli.flags = ANDROID_DLEXT_USE_LIBRARY_FD | ANDROID_DLEXT_USE_LIBRARY_FD_OFFSET;
1122- dli.library_fd = apk_entry->fd ;
1123- dli.library_fd_offset = apk_entry->offset ;
1124- dso->handle = android_dlopen_ext (dso->name , flags, &dli);
1125-
1126- if (dso->handle != nullptr ) {
1127- return monodroid_dlopen_log_and_return (dso->handle , err, dso->name , false /* name_needs_free */ );
1128- }
1129- break ;
1130- }
1131- }
1132- #endif
1133- unsigned int dl_flags = monodroidRuntime.convert_dl_flags (flags);
1134- dso->handle = AndroidSystem::load_dso_from_any_directories (dso->name , dl_flags);
1135-
1136- if (dso->handle != nullptr ) {
1137- return monodroid_dlopen_log_and_return (dso->handle , err, dso->name , false /* name_needs_free */ );
1138- }
1139-
1140- dso->handle = AndroidSystem::load_dso_from_any_directories (name, dl_flags);
1141- return monodroid_dlopen_log_and_return (dso->handle , err, name, false /* name_needs_free */ );
1142- }
1143-
1144- void *
1145- MonodroidRuntime::monodroid_dlopen (const char *name, int flags, char **err, [[maybe_unused]] void *user_data) noexcept
1146- {
1147- if (name == nullptr ) {
1148- log_warn (LOG_ASSEMBLY, " monodroid_dlopen got a null name. This is not supported in NET+" );
1149- return nullptr ;
1150- }
1151-
1152- return monodroid_dlopen (name, flags, err);
1153- }
1154-
1155- void *
1156- MonodroidRuntime::monodroid_dlsym (void *handle, const char *name, char **err, [[maybe_unused]] void *user_data)
1157- {
1158- void *s;
1159- char *e = nullptr ;
1160-
1161- s = java_interop_lib_symbol (handle, name, &e);
1162-
1163- if (!s && err) {
1164- *err = Util::monodroid_strdup_printf (" Could not find symbol '%s': %s" , name, e);
1165- }
1166- if (e) {
1167- java_interop_free (e);
1168- }
1169-
1170- return s;
1171- }
1172-
11731004inline void
11741005MonodroidRuntime::set_environment_variable_for_directory (const char *name, jstring_wrapper &value, bool createDirectory, mode_t mode)
11751006{
@@ -1650,7 +1481,7 @@ MonodroidRuntime::Java_mono_android_Runtime_initInternal (JNIEnv *env, jclass kl
16501481 }
16511482
16521483 AndroidSystem::setup_process_args (runtimeApks);
1653- mono_dl_fallback_register (monodroid_dlopen, monodroid_dlsym, nullptr , nullptr );
1484+ mono_dl_fallback_register (MonodroidDl:: monodroid_dlopen, MonodroidDl:: monodroid_dlsym, nullptr , nullptr );
16541485
16551486 set_profile_options ();
16561487
0 commit comments