@@ -34,6 +34,7 @@ namespace art {
34
34
LOGD (" Pending hook for %p (%s)" , clazz_ptr,
35
35
art::mirror::Class (clazz_ptr).GetDescriptor ().c_str ());
36
36
edxp::Context::GetInstance ()->CallOnPostFixupStaticTrampolines (clazz_ptr);
37
+ edxp::DonePendingHook (class_def);
37
38
}
38
39
}
39
40
@@ -45,11 +46,12 @@ namespace art {
45
46
});
46
47
47
48
CREATE_MEM_HOOK_STUB_ENTRIES (
48
- " _ZN3art11ClassLinker22FixupStaticTrampolinesEPNS_6ThreadENS_6ObjPtrINS_6mirror5ClassEEE" ,
49
- void , FixupStaticTrampolinesWithThread, (void * thiz,
50
- void * thread, void * clazz_ptr), {
51
- backup (thiz, thread, clazz_ptr);
52
- MaybeDelayHook (clazz_ptr);
49
+ " _ZN3art11ClassLinker20MarkClassInitializedEPNS_6ThreadENS_6HandleINS_6mirror5ClassEEE" ,
50
+ void *, MarkClassInitialized, (void * thiz, void * self, uint32_t * clazz_ptr), {
51
+ void *result = backup (thiz, self, clazz_ptr);
52
+ auto ptr = reinterpret_cast <void *>(*clazz_ptr);
53
+ MaybeDelayHook (ptr);
54
+ return result;
53
55
});
54
56
55
57
CREATE_MEM_FUNC_SYMBOL_ENTRY (void , MakeInitializedClassesVisiblyInitialized, void *thiz,
@@ -63,7 +65,7 @@ namespace art {
63
65
" _ZN3art11ClassLinker30ShouldUseInterpreterEntrypointEPNS_9ArtMethodEPKv" ,
64
66
bool , ShouldUseInterpreterEntrypoint, (void * art_method,
65
67
const void *quick_code), {
66
- if (quick_code != nullptr && UNLIKELY (edxp::isHooked (art_method))) {
68
+ if (quick_code != nullptr && UNLIKELY (edxp::isHooked (art_method) || edxp::IsMethodPending (art_method) )) {
67
69
return false ;
68
70
}
69
71
return backup (art_method, quick_code);
@@ -126,10 +128,19 @@ namespace art {
126
128
RETRIEVE_MEM_FUNC_SYMBOL (SetEntryPointsToInterpreter,
127
129
" _ZNK3art11ClassLinker27SetEntryPointsToInterpreterEPNS_9ArtMethodE" );
128
130
129
- edxp::HookSyms (handle, hook_func, FixupStaticTrampolines,
130
- FixupStaticTrampolinesWithThread);
131
131
edxp::HookSyms (handle, hook_func, ShouldUseInterpreterEntrypoint);
132
132
133
+ if (api_level >= __ANDROID_API_R__) {
134
+ // In android R, FixupStaticTrampolines won't be called unless it's marking it as
135
+ // visiblyInitialized.
136
+ // So we miss some calls between initialized and visiblyInitialized.
137
+ // Therefore we hook the new introduced MarkClassInitialized instead
138
+ // This only happens on non-x86 devices
139
+ edxp::HookSyms (handle, hook_func, MarkClassInitialized);
140
+ } else {
141
+ edxp::HookSyms (handle, hook_func, FixupStaticTrampolines);
142
+ }
143
+
133
144
// MakeInitializedClassesVisiblyInitialized will cause deadlock
134
145
// IsQuickToInterpreterBridge is inlined
135
146
// So we use GetSavedEntryPointOfPreCompiledMethod instead
0 commit comments