diff --git a/build-tools/create-packs/Microsoft.Android.Runtime.proj b/build-tools/create-packs/Microsoft.Android.Runtime.proj
index d20f8f00eaa..9e8a593f6f0 100644
--- a/build-tools/create-packs/Microsoft.Android.Runtime.proj
+++ b/build-tools/create-packs/Microsoft.Android.Runtime.proj
@@ -61,8 +61,6 @@ projects that use the Microsoft.Android.Runtimes framework in .NET 6+.
-
-
diff --git a/src/Xamarin.Android.Build.Tasks/Utilities/NativeRuntimeComponents.cs b/src/Xamarin.Android.Build.Tasks/Utilities/NativeRuntimeComponents.cs
index 141bab21947..6234630b914 100644
--- a/src/Xamarin.Android.Build.Tasks/Utilities/NativeRuntimeComponents.cs
+++ b/src/Xamarin.Android.Build.Tasks/Utilities/NativeRuntimeComponents.cs
@@ -121,7 +121,6 @@ public NativeRuntimeComponents (ITaskItem[]? monoComponents)
// .NET for Android
new AndroidArchive ("libnet-android.release-static-release.a", wholeArchive: true),
- new AndroidArchive ("libpinvoke-override-dynamic-release.a", wholeArchive: true),
new AndroidArchive ("libruntime-base-common-release.a"),
new AndroidArchive ("libruntime-base-release.a"),
new AndroidArchive ("libxa-java-interop-release.a"),
diff --git a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets
index 1b4b676cb37..5cc9126552c 100644
--- a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets
+++ b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets
@@ -348,10 +348,6 @@ Copyright (C) 2011-2012 Xamarin. All rights reserved.
<_AndroidUseManagedMarshalMethodsLookup Condition=" '$(_AndroidUseManagedMarshalMethodsLookup)' == '' and '$(_AndroidUseMarshalMethods)' == 'True' and '$(_AndroidRuntime)' != 'MonoVM' ">True
<_AndroidUseManagedMarshalMethodsLookup Condition=" '$(_AndroidUseManagedMarshalMethodsLookup)' == '' ">False
-
-
- <_AndroidEnableNativeRuntimeLinking Condition=" '$(_AndroidRuntime)' != 'CoreCLR' ">false
- <_AndroidEnableNativeRuntimeLinking Condition=" '$(AndroidIncludeDebugSymbols)' == 'true' And '$(_AndroidRuntime)' == 'CoreCLR' ">false
diff --git a/src/native/clr/pinvoke-override/CMakeLists.txt b/src/native/clr/pinvoke-override/CMakeLists.txt
index b1f35a16e2f..44d9fc1e16c 100644
--- a/src/native/clr/pinvoke-override/CMakeLists.txt
+++ b/src/native/clr/pinvoke-override/CMakeLists.txt
@@ -1,19 +1,11 @@
set(LIB_NAME_PRECOMPILED pinvoke-override-precompiled)
set(LIB_ALIAS_PRECOMPILED xa::pinvoke-override-precompiled)
-set(LIB_NAME_DYNAMIC pinvoke-override-dynamic)
-set(LIB_ALIAS_DYNAMIC xa::pinvoke-override-dynamic)
-
set(XA_PINVOKE_OVERRIDE_PRECOMPILED_SOURCES
precompiled.cc
)
add_clang_check_sources("${XA_PINVOKE_OVERRIDE_PRECOMPILED_SOURCES}")
-set(XA_PINVOKE_OVERRIDE_DYNAMIC_SOURCES
- dynamic.cc
-)
-add_clang_check_sources("${XA_PINVOKE_OVERRIDE_DYNAMIC_SOURCES}")
-
list(APPEND POTENTIAL_LOCAL_COMPILER_ARGS
-ffunction-sections
-fdata-sections
@@ -77,7 +69,6 @@ macro(create_library _libname _alias _sources)
endmacro()
create_library(${LIB_NAME_PRECOMPILED} ${LIB_ALIAS_PRECOMPILED} ${XA_PINVOKE_OVERRIDE_PRECOMPILED_SOURCES})
-create_library(${LIB_NAME_DYNAMIC} ${LIB_ALIAS_DYNAMIC} ${XA_PINVOKE_OVERRIDE_DYNAMIC_SOURCES})
target_compile_definitions(
${LIB_NAME_PRECOMPILED}
diff --git a/src/native/clr/pinvoke-override/dynamic.cc b/src/native/clr/pinvoke-override/dynamic.cc
deleted file mode 100644
index 5352aacab68..00000000000
--- a/src/native/clr/pinvoke-override/dynamic.cc
+++ /dev/null
@@ -1,103 +0,0 @@
-#include
-
-#include
-
-#define PINVOKE_OVERRIDE_INLINE [[gnu::noinline]]
-#include
-
-using namespace xamarin::android;
-
-using JniOnLoadHandler = jint (*) (JavaVM *vm, void *reserved);
-
-//
-// These external functions are generated during application build (see obj/${CONFIGURATION}/${RID}/android/pinvoke_preserve.*.ll)
-//
-extern "C" {
- void* find_pinvoke (hash_t library_name_hash, hash_t entrypoint_hash, bool &known_library);
-
- extern const uint32_t __jni_on_load_handler_count;
- extern const JniOnLoadHandler __jni_on_load_handlers[];
- extern const char* __jni_on_load_handler_names[];
- extern const void* __explicitly_preserved_symbols[];
-}
-
-[[gnu::flatten]]
-auto PinvokeOverride::monodroid_pinvoke_override (const char *library_name, const char *entrypoint_name) noexcept -> void*
-{
- log_debug (LOG_ASSEMBLY, "library_name == '{}'; entrypoint_name == '{}'"sv, optional_string (library_name), optional_string (entrypoint_name));
-
- if (library_name == nullptr || entrypoint_name == nullptr) [[unlikely]] {
- Helpers::abort_application (
- LOG_ASSEMBLY,
- std::format (
- "Both library name ('{}') and entry point name ('{}') must be specified"sv,
- optional_string (library_name),
- optional_string (entrypoint_name)
- )
- );
- }
-
- hash_t library_name_hash = xxhash::hash (library_name, strlen (library_name));
- hash_t entrypoint_hash = xxhash::hash (entrypoint_name, strlen (entrypoint_name));
- log_debug (LOG_ASSEMBLY, "library_name_hash == 0x{:x}; entrypoint_hash == 0x{:x}"sv, library_name_hash, entrypoint_hash);
-
- bool known_library = true;
- void *pinvoke_ptr = find_pinvoke (library_name_hash, entrypoint_hash, known_library);
- if (pinvoke_ptr != nullptr) [[likely]] {
- log_debug (LOG_ASSEMBLY, "pinvoke_ptr == {:p}"sv, pinvoke_ptr);
- return pinvoke_ptr;
- }
-
- if (known_library) [[unlikely]] {
- log_debug (LOG_ASSEMBLY, "Lookup in a known library == internal"sv);
- // Should "never" happen. It seems we have a known library hash (of one that's linked into the dynamically
- // built DSO) but an unknown symbol hash. The symbol **probably** doesn't exist (was most likely linked out if
- // the find* functions didn't know its hash), but we cannot be sure of that so we'll try to load it.
- pinvoke_ptr = dlsym (RTLD_DEFAULT, entrypoint_name);
- if (pinvoke_ptr == nullptr) {
- Helpers::abort_application (
- LOG_ASSEMBLY,
- std::format (
- "Unable to load p/invoke entry '{}/{}' from the unified runtime DSO"sv,
- optional_string (library_name),
- optional_string (entrypoint_name)
- )
- );
- }
-
- return pinvoke_ptr;
- }
-
- log_debug (LOG_ASSEMBLY, "p/invoke not from a known library, slow path taken."sv);
- pinvoke_ptr = handle_other_pinvoke_request (library_name, library_name_hash, entrypoint_name, entrypoint_hash);
- log_debug (LOG_ASSEMBLY, "foreign library pinvoke_ptr == {:p}"sv, pinvoke_ptr);
- return pinvoke_ptr;
-}
-
-void PinvokeOverride::handle_jni_on_load (JavaVM *vm, void *reserved) noexcept
-{
- if (__jni_on_load_handler_count == 0) {
- return;
- }
-
- for (uint32_t i = 0; i < __jni_on_load_handler_count; i++) {
- __jni_on_load_handlers[i] (vm, reserved);
- }
-
- // This is just to reference the generated array, all we need from it is to be there
- // TODO: see if there's an attribute we can use to make the linker keep the symbol instead.
- // void *first_ptr = __explicitly_preserved_symbols;
- // if (first_ptr == nullptr) {
- // // This will never actually be logged, since by the time this function is called we haven't initialized
- // // logging categories yet. It's here just to have some code in the if statement body.
- // log_debug (LOG_ASSEMBLY, "No explicitly preserved symbols");
- // }
-}
-
-const void* Host::clr_pinvoke_override (const char *library_name, const char *entry_point_name) noexcept
-{
- log_debug (LOG_ASSEMBLY, "[dynamic] clr_pinvoke_override (\"{}\", \"{}\")"sv, optional_string (library_name), optional_string (entry_point_name));
- void *ret = PinvokeOverride::monodroid_pinvoke_override (library_name, entry_point_name);
- log_debug (LOG_DEFAULT, "[dynamic] p/invoke {}found", ret == nullptr ? "not "sv : ""sv);
- return ret;
-}
diff --git a/src/native/clr/pinvoke-override/precompiled.cc b/src/native/clr/pinvoke-override/precompiled.cc
index a57748bdb4e..09d151a85ea 100644
--- a/src/native/clr/pinvoke-override/precompiled.cc
+++ b/src/native/clr/pinvoke-override/precompiled.cc
@@ -53,10 +53,6 @@ auto PinvokeOverride::monodroid_pinvoke_override (const char *library_name, cons
// Measurements on a physical device showed the table provides no measurable startup benefit, so
// we return `nullptr` for these libraries and let CoreCLR's own resolver handle them, removing
// the whole class of drift bugs.
- //
- // NOTE: this only affects the precompiled override used by the default separate-`.so` layout.
- // The unified-DSO layout uses the generated `find_pinvoke` table in `dynamic.cc`, where these
- // symbols are hidden inside a single DSO and therefore must still be resolved by the override.
if (library_name_hash == system_native_library_hash ||
library_name_hash == system_security_cryptography_native_android_library_hash ||
library_name_hash == system_io_compression_native_library_hash ||