From ab5830a0207a76cc2abc82e6d4f15f2053f51523 Mon Sep 17 00:00:00 2001 From: LoveSy Date: Wed, 26 Jul 2023 15:56:26 +0800 Subject: [PATCH] Hook if `ShouldUseInterpreterEntrypoint` This will not be inlined --- .../src/main/jni/art/runtime/class_linker.hpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/lsplant/src/main/jni/art/runtime/class_linker.hpp b/lsplant/src/main/jni/art/runtime/class_linker.hpp index 004370a..10c40e9 100644 --- a/lsplant/src/main/jni/art/runtime/class_linker.hpp +++ b/lsplant/src/main/jni/art/runtime/class_linker.hpp @@ -15,6 +15,16 @@ private: } } + CREATE_HOOK_STUB_ENTRY( + "_ZN3art11ClassLinker30ShouldUseInterpreterEntrypointEPNS_9ArtMethodEPKv", bool, + ShouldUseInterpreterEntrypoint, (ArtMethod * art_method, const void *quick_code), { + if (quick_code != nullptr && IsHooked(art_method)) [[unlikely]] { + return false; + } + return backup(art_method, quick_code); + }); + + CREATE_FUNC_SYMBOL_ENTRY(void, art_quick_to_interpreter_bridge, void *) {} CREATE_FUNC_SYMBOL_ENTRY(void, art_quick_generic_jni_trampoline, void *) {} @@ -119,6 +129,12 @@ private: public: static bool Init(const HookHandler &handler) { + int sdk_int = GetAndroidApiLevel(); + + if (sdk_int >= __ANDROID_API_N__) [[likely]] { + !HookSyms(handler, ShouldUseInterpreterEntrypoint); + } + if (!HookSyms(handler, FixupStaticTrampolinesWithThread, FixupStaticTrampolines, FixupStaticTrampolinesRaw)) { return false; @@ -131,8 +147,6 @@ public: return false; } - int sdk_int = GetAndroidApiLevel(); - if (sdk_int >= __ANDROID_API_R__) { if constexpr (GetArch() != Arch::kX86 && GetArch() != Arch::kX86_64) { // fixup static trampoline may have been inlined