1 //
2 // Copyright (C) 2020 The Android Open Source Project
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 // clang-format off
18 #include "native_bridge_support/vdso/interceptable_functions.h"
19
20 DEFINE_INTERCEPTABLE_STUB_FUNCTION(JNI_CreateJavaVM);
21 DEFINE_INTERCEPTABLE_STUB_FUNCTION(JNI_GetCreatedJavaVMs);
22 DEFINE_INTERCEPTABLE_STUB_FUNCTION(JNI_GetDefaultJavaVMInitArgs);
23 DEFINE_INTERCEPTABLE_STUB_FUNCTION(JniInvocationCreate);
24 DEFINE_INTERCEPTABLE_STUB_FUNCTION(JniInvocationDestroy);
25 DEFINE_INTERCEPTABLE_STUB_FUNCTION(JniInvocationGetLibrary);
26 DEFINE_INTERCEPTABLE_STUB_FUNCTION(JniInvocationInit);
27 DEFINE_INTERCEPTABLE_STUB_FUNCTION(_ZN12JniConstants12UninitializeEv);
28 DEFINE_INTERCEPTABLE_STUB_FUNCTION(_ZN12JniConstants14GetStringClassEP7_JNIEnv);
29 DEFINE_INTERCEPTABLE_STUB_FUNCTION(_ZN12JniConstants17GetNioAccessClassEP7_JNIEnv);
30 DEFINE_INTERCEPTABLE_STUB_FUNCTION(_ZN12JniConstants17GetNioBufferClassEP7_JNIEnv);
31 DEFINE_INTERCEPTABLE_STUB_FUNCTION(_ZN12JniConstants17GetReferenceClassEP7_JNIEnv);
32 DEFINE_INTERCEPTABLE_STUB_FUNCTION(_ZN12JniConstants21GetReferenceGetMethodEP7_JNIEnv);
33 DEFINE_INTERCEPTABLE_STUB_FUNCTION(_ZN12JniConstants22GetFileDescriptorClassEP7_JNIEnv);
34 DEFINE_INTERCEPTABLE_STUB_FUNCTION(_ZN12JniConstants22GetNioBufferLimitFieldEP7_JNIEnv);
35 DEFINE_INTERCEPTABLE_STUB_FUNCTION(_ZN12JniConstants23GetNioBufferArrayMethodEP7_JNIEnv);
36 DEFINE_INTERCEPTABLE_STUB_FUNCTION(_ZN12JniConstants24GetNioBufferAddressFieldEP7_JNIEnv);
37 DEFINE_INTERCEPTABLE_STUB_FUNCTION(_ZN12JniConstants25GetNioBufferPositionFieldEP7_JNIEnv);
38 DEFINE_INTERCEPTABLE_STUB_FUNCTION(_ZN12JniConstants27GetFileDescriptorInitMethodEP7_JNIEnv);
39 DEFINE_INTERCEPTABLE_STUB_FUNCTION(_ZN12JniConstants29GetFileDescriptorOwnerIdFieldEP7_JNIEnv);
40 DEFINE_INTERCEPTABLE_STUB_FUNCTION(_ZN12JniConstants29GetNioBufferArrayOffsetMethodEP7_JNIEnv);
41 DEFINE_INTERCEPTABLE_STUB_FUNCTION(_ZN12JniConstants30GetNioAccessGetBaseArrayMethodEP7_JNIEnv);
42 DEFINE_INTERCEPTABLE_STUB_FUNCTION(_ZN12JniConstants32EnsureClassReferencesInitializedEP7_JNIEnv);
43 DEFINE_INTERCEPTABLE_STUB_FUNCTION(_ZN12JniConstants32GetFileDescriptorDescriptorFieldEP7_JNIEnv);
44 DEFINE_INTERCEPTABLE_STUB_FUNCTION(_ZN12JniConstants33GetNioBufferElementSizeShiftFieldEP7_JNIEnv);
45 DEFINE_INTERCEPTABLE_STUB_FUNCTION(_ZN12JniConstants36GetNioAccessGetBaseArrayOffsetMethodEP7_JNIEnv);
46 DEFINE_INTERCEPTABLE_STUB_FUNCTION(_ZN13JniInvocation10GetLibraryEPKcPcPFbvEPFiS2_E);
47 DEFINE_INTERCEPTABLE_STUB_FUNCTION(_ZN17JniInvocationImpl10FindSymbolEPPvPKc);
48 DEFINE_INTERCEPTABLE_STUB_FUNCTION(_ZN17JniInvocationImpl10GetLibraryEPKcPcPFbvEPFiS2_E);
49 DEFINE_INTERCEPTABLE_STUB_FUNCTION(_ZN17JniInvocationImpl16GetJniInvocationEv);
50 DEFINE_INTERCEPTABLE_STUB_FUNCTION(_ZN17JniInvocationImpl16JNI_CreateJavaVMEPP7_JavaVMPP7_JNIEnvPv);
51 DEFINE_INTERCEPTABLE_STUB_FUNCTION(_ZN17JniInvocationImpl21JNI_GetCreatedJavaVMsEPP7_JavaVMiPi);
52 DEFINE_INTERCEPTABLE_STUB_FUNCTION(_ZN17JniInvocationImpl28JNI_GetDefaultJavaVMInitArgsEPv);
53 DEFINE_INTERCEPTABLE_STUB_FUNCTION(_ZN17JniInvocationImpl4InitEPKc);
54 DEFINE_INTERCEPTABLE_STUB_FUNCTION(_ZN17JniInvocationImplC2Ev);
55 DEFINE_INTERCEPTABLE_STUB_FUNCTION(_ZN17JniInvocationImplD2Ev);
56 DEFINE_INTERCEPTABLE_STUB_FUNCTION(jniCreateFileDescriptor);
57 DEFINE_INTERCEPTABLE_STUB_FUNCTION(jniCreateString);
58 DEFINE_INTERCEPTABLE_STUB_FUNCTION(jniGetFDFromFileDescriptor);
59 DEFINE_INTERCEPTABLE_STUB_FUNCTION(jniGetNioBufferBaseArray);
60 DEFINE_INTERCEPTABLE_STUB_FUNCTION(jniGetNioBufferBaseArrayOffset);
61 DEFINE_INTERCEPTABLE_STUB_FUNCTION(jniGetNioBufferFields);
62 DEFINE_INTERCEPTABLE_STUB_FUNCTION(jniGetNioBufferPointer);
63 DEFINE_INTERCEPTABLE_STUB_FUNCTION(jniGetOwnerIdFromFileDescriptor);
64 DEFINE_INTERCEPTABLE_STUB_FUNCTION(jniGetReferent);
65 DEFINE_INTERCEPTABLE_STUB_FUNCTION(jniLogException);
66 DEFINE_INTERCEPTABLE_STUB_FUNCTION(jniRegisterNativeMethods);
67 DEFINE_INTERCEPTABLE_STUB_FUNCTION(jniSetFileDescriptorOfFD);
68 DEFINE_INTERCEPTABLE_STUB_FUNCTION(jniStrError);
69 DEFINE_INTERCEPTABLE_STUB_FUNCTION(jniThrowException);
70 DEFINE_INTERCEPTABLE_STUB_FUNCTION(jniThrowExceptionFmt);
71 DEFINE_INTERCEPTABLE_STUB_FUNCTION(jniThrowIOException);
72 DEFINE_INTERCEPTABLE_STUB_FUNCTION(jniThrowNullPointerException);
73 DEFINE_INTERCEPTABLE_STUB_FUNCTION(jniThrowRuntimeException);
74 DEFINE_INTERCEPTABLE_STUB_FUNCTION(jniUninitializeConstants);
75 DEFINE_INTERCEPTABLE_STUB_FUNCTION(newStringArray);
76 DEFINE_INTERCEPTABLE_STUB_FUNCTION(toStringArray);
77
init_stub_library()78 static void __attribute__((constructor(0))) init_stub_library() {
79 INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", JNI_CreateJavaVM);
80 INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", JNI_GetCreatedJavaVMs);
81 INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", JNI_GetDefaultJavaVMInitArgs);
82 INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", JniInvocationCreate);
83 INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", JniInvocationDestroy);
84 INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", JniInvocationGetLibrary);
85 INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", JniInvocationInit);
86 INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", _ZN12JniConstants12UninitializeEv);
87 INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", _ZN12JniConstants14GetStringClassEP7_JNIEnv);
88 INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", _ZN12JniConstants17GetNioAccessClassEP7_JNIEnv);
89 INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", _ZN12JniConstants17GetNioBufferClassEP7_JNIEnv);
90 INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", _ZN12JniConstants17GetReferenceClassEP7_JNIEnv);
91 INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", _ZN12JniConstants21GetReferenceGetMethodEP7_JNIEnv);
92 INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", _ZN12JniConstants22GetFileDescriptorClassEP7_JNIEnv);
93 INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", _ZN12JniConstants22GetNioBufferLimitFieldEP7_JNIEnv);
94 INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", _ZN12JniConstants23GetNioBufferArrayMethodEP7_JNIEnv);
95 INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", _ZN12JniConstants24GetNioBufferAddressFieldEP7_JNIEnv);
96 INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", _ZN12JniConstants25GetNioBufferPositionFieldEP7_JNIEnv);
97 INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", _ZN12JniConstants27GetFileDescriptorInitMethodEP7_JNIEnv);
98 INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", _ZN12JniConstants29GetFileDescriptorOwnerIdFieldEP7_JNIEnv);
99 INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", _ZN12JniConstants29GetNioBufferArrayOffsetMethodEP7_JNIEnv);
100 INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", _ZN12JniConstants30GetNioAccessGetBaseArrayMethodEP7_JNIEnv);
101 INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", _ZN12JniConstants32EnsureClassReferencesInitializedEP7_JNIEnv);
102 INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", _ZN12JniConstants32GetFileDescriptorDescriptorFieldEP7_JNIEnv);
103 INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", _ZN12JniConstants33GetNioBufferElementSizeShiftFieldEP7_JNIEnv);
104 INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", _ZN12JniConstants36GetNioAccessGetBaseArrayOffsetMethodEP7_JNIEnv);
105 INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", _ZN13JniInvocation10GetLibraryEPKcPcPFbvEPFiS2_E);
106 INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", _ZN17JniInvocationImpl10FindSymbolEPPvPKc);
107 INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", _ZN17JniInvocationImpl10GetLibraryEPKcPcPFbvEPFiS2_E);
108 INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", _ZN17JniInvocationImpl16GetJniInvocationEv);
109 INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", _ZN17JniInvocationImpl16JNI_CreateJavaVMEPP7_JavaVMPP7_JNIEnvPv);
110 INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", _ZN17JniInvocationImpl21JNI_GetCreatedJavaVMsEPP7_JavaVMiPi);
111 INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", _ZN17JniInvocationImpl28JNI_GetDefaultJavaVMInitArgsEPv);
112 INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", _ZN17JniInvocationImpl4InitEPKc);
113 INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", _ZN17JniInvocationImplC2Ev);
114 INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", _ZN17JniInvocationImplD2Ev);
115 INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", jniCreateFileDescriptor);
116 INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", jniCreateString);
117 INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", jniGetFDFromFileDescriptor);
118 INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", jniGetNioBufferBaseArray);
119 INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", jniGetNioBufferBaseArrayOffset);
120 INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", jniGetNioBufferFields);
121 INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", jniGetNioBufferPointer);
122 INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", jniGetOwnerIdFromFileDescriptor);
123 INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", jniGetReferent);
124 INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", jniLogException);
125 INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", jniRegisterNativeMethods);
126 INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", jniSetFileDescriptorOfFD);
127 INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", jniStrError);
128 INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", jniThrowException);
129 INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", jniThrowExceptionFmt);
130 INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", jniThrowIOException);
131 INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", jniThrowNullPointerException);
132 INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", jniThrowRuntimeException);
133 INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", jniUninitializeConstants);
134 INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", newStringArray);
135 INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", toStringArray);
136 }
137 // clang-format on
138