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(AFileDescriptor_create);
21 DEFINE_INTERCEPTABLE_STUB_FUNCTION(AFileDescriptor_getFD);
22 DEFINE_INTERCEPTABLE_STUB_FUNCTION(AFileDescriptor_setFD);
23 DEFINE_INTERCEPTABLE_STUB_FUNCTION(DlCloseLibrary);
24 DEFINE_INTERCEPTABLE_STUB_FUNCTION(DlGetError);
25 DEFINE_INTERCEPTABLE_STUB_FUNCTION(DlGetSymbol);
26 DEFINE_INTERCEPTABLE_STUB_FUNCTION(DlOpenLibrary);
27 DEFINE_INTERCEPTABLE_STUB_FUNCTION(EnsureInitialized);
28 DEFINE_INTERCEPTABLE_STUB_FUNCTION(ExpandableStringAppend);
29 DEFINE_INTERCEPTABLE_STUB_FUNCTION(ExpandableStringAssign);
30 DEFINE_INTERCEPTABLE_STUB_FUNCTION(ExpandableStringInitialize);
31 DEFINE_INTERCEPTABLE_STUB_FUNCTION(ExpandableStringRelease);
32 DEFINE_INTERCEPTABLE_STUB_FUNCTION(JNI_CreateJavaVM);
33 DEFINE_INTERCEPTABLE_STUB_FUNCTION(JNI_GetCreatedJavaVMs);
34 DEFINE_INTERCEPTABLE_STUB_FUNCTION(JNI_GetDefaultJavaVMInitArgs);
35 DEFINE_INTERCEPTABLE_STUB_FUNCTION(JniConstants_FileDescriptorClass);
36 DEFINE_INTERCEPTABLE_STUB_FUNCTION(JniConstants_FileDescriptor_descriptor);
37 DEFINE_INTERCEPTABLE_STUB_FUNCTION(JniConstants_FileDescriptor_init);
38 DEFINE_INTERCEPTABLE_STUB_FUNCTION(JniConstants_NIOAccessClass);
39 DEFINE_INTERCEPTABLE_STUB_FUNCTION(JniConstants_NIOAccess_getBaseArray);
40 DEFINE_INTERCEPTABLE_STUB_FUNCTION(JniConstants_NIOAccess_getBaseArrayOffset);
41 DEFINE_INTERCEPTABLE_STUB_FUNCTION(JniConstants_NioBufferClass);
42 DEFINE_INTERCEPTABLE_STUB_FUNCTION(JniConstants_NioBuffer__elementSizeShift);
43 DEFINE_INTERCEPTABLE_STUB_FUNCTION(JniConstants_NioBuffer_address);
44 DEFINE_INTERCEPTABLE_STUB_FUNCTION(JniConstants_NioBuffer_array);
45 DEFINE_INTERCEPTABLE_STUB_FUNCTION(JniConstants_NioBuffer_arrayOffset);
46 DEFINE_INTERCEPTABLE_STUB_FUNCTION(JniConstants_NioBuffer_limit);
47 DEFINE_INTERCEPTABLE_STUB_FUNCTION(JniConstants_NioBuffer_position);
48 DEFINE_INTERCEPTABLE_STUB_FUNCTION(JniInvocationCreate);
49 DEFINE_INTERCEPTABLE_STUB_FUNCTION(JniInvocationDestroy);
50 DEFINE_INTERCEPTABLE_STUB_FUNCTION(JniInvocationGetLibrary);
51 DEFINE_INTERCEPTABLE_STUB_FUNCTION(JniInvocationGetLibraryWith);
52 DEFINE_INTERCEPTABLE_STUB_FUNCTION(JniInvocationInit);
53 DEFINE_INTERCEPTABLE_STUB_FUNCTION(jniCreateFileDescriptor);
54 DEFINE_INTERCEPTABLE_STUB_FUNCTION(jniCreateString);
55 DEFINE_INTERCEPTABLE_STUB_FUNCTION(jniCreateStringArray);
56 DEFINE_INTERCEPTABLE_STUB_FUNCTION(jniGetFDFromFileDescriptor);
57 DEFINE_INTERCEPTABLE_STUB_FUNCTION(jniGetNioBufferBaseArray);
58 DEFINE_INTERCEPTABLE_STUB_FUNCTION(jniGetNioBufferBaseArrayOffset);
59 DEFINE_INTERCEPTABLE_STUB_FUNCTION(jniGetNioBufferFields);
60 DEFINE_INTERCEPTABLE_STUB_FUNCTION(jniGetNioBufferPointer);
61 DEFINE_INTERCEPTABLE_STUB_FUNCTION(jniGetReferent);
62 DEFINE_INTERCEPTABLE_STUB_FUNCTION(jniLogException);
63 DEFINE_INTERCEPTABLE_STUB_FUNCTION(jniRegisterNativeMethods);
64 DEFINE_INTERCEPTABLE_STUB_FUNCTION(jniSetFileDescriptorOfFD);
65 DEFINE_INTERCEPTABLE_STUB_FUNCTION(jniThrowException);
66 DEFINE_INTERCEPTABLE_STUB_FUNCTION(jniThrowExceptionFmt);
67 DEFINE_INTERCEPTABLE_STUB_FUNCTION(jniThrowIOException);
68 DEFINE_INTERCEPTABLE_STUB_FUNCTION(jniThrowNullPointerException);
69 DEFINE_INTERCEPTABLE_STUB_FUNCTION(jniThrowRuntimeException);
70 DEFINE_INTERCEPTABLE_STUB_FUNCTION(jniUninitializeConstants);
71 
init_stub_library()72 static void __attribute__((constructor(0))) init_stub_library() {
73   INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", AFileDescriptor_create);
74   INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", AFileDescriptor_getFD);
75   INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", AFileDescriptor_setFD);
76   INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", DlCloseLibrary);
77   INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", DlGetError);
78   INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", DlGetSymbol);
79   INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", DlOpenLibrary);
80   INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", EnsureInitialized);
81   INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", ExpandableStringAppend);
82   INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", ExpandableStringAssign);
83   INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", ExpandableStringInitialize);
84   INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", ExpandableStringRelease);
85   INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", JNI_CreateJavaVM);
86   INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", JNI_GetCreatedJavaVMs);
87   INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", JNI_GetDefaultJavaVMInitArgs);
88   INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", JniConstants_FileDescriptorClass);
89   INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", JniConstants_FileDescriptor_descriptor);
90   INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", JniConstants_FileDescriptor_init);
91   INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", JniConstants_NIOAccessClass);
92   INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", JniConstants_NIOAccess_getBaseArray);
93   INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", JniConstants_NIOAccess_getBaseArrayOffset);
94   INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", JniConstants_NioBufferClass);
95   INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", JniConstants_NioBuffer__elementSizeShift);
96   INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", JniConstants_NioBuffer_address);
97   INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", JniConstants_NioBuffer_array);
98   INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", JniConstants_NioBuffer_arrayOffset);
99   INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", JniConstants_NioBuffer_limit);
100   INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", JniConstants_NioBuffer_position);
101   INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", JniInvocationCreate);
102   INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", JniInvocationDestroy);
103   INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", JniInvocationGetLibrary);
104   INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", JniInvocationGetLibraryWith);
105   INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", JniInvocationInit);
106   INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", jniCreateFileDescriptor);
107   INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", jniCreateString);
108   INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", jniCreateStringArray);
109   INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", jniGetFDFromFileDescriptor);
110   INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", jniGetNioBufferBaseArray);
111   INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", jniGetNioBufferBaseArrayOffset);
112   INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", jniGetNioBufferFields);
113   INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", jniGetNioBufferPointer);
114   INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", jniGetReferent);
115   INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", jniLogException);
116   INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", jniRegisterNativeMethods);
117   INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", jniSetFileDescriptorOfFD);
118   INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", jniThrowException);
119   INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", jniThrowExceptionFmt);
120   INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", jniThrowIOException);
121   INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", jniThrowNullPointerException);
122   INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", jniThrowRuntimeException);
123   INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", jniUninitializeConstants);
124 }
125 // clang-format on
126