blob: 12815895591aca3f26d22593c284767a7f3b34b9 [file] [log] [blame]
Bob Badour07562132020-05-20 13:18:00 +00001//
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
Evgeny Eltsin9c7d4622020-07-15 15:30:51 +020020DEFINE_INTERCEPTABLE_STUB_FUNCTION(AFileDescriptor_create);
21DEFINE_INTERCEPTABLE_STUB_FUNCTION(AFileDescriptor_getFD);
22DEFINE_INTERCEPTABLE_STUB_FUNCTION(AFileDescriptor_setFD);
23DEFINE_INTERCEPTABLE_STUB_FUNCTION(DlCloseLibrary);
24DEFINE_INTERCEPTABLE_STUB_FUNCTION(DlGetError);
25DEFINE_INTERCEPTABLE_STUB_FUNCTION(DlGetSymbol);
26DEFINE_INTERCEPTABLE_STUB_FUNCTION(DlOpenLibrary);
27DEFINE_INTERCEPTABLE_STUB_FUNCTION(EnsureInitialized);
28DEFINE_INTERCEPTABLE_STUB_FUNCTION(ExpandableStringAppend);
29DEFINE_INTERCEPTABLE_STUB_FUNCTION(ExpandableStringAssign);
30DEFINE_INTERCEPTABLE_STUB_FUNCTION(ExpandableStringInitialize);
31DEFINE_INTERCEPTABLE_STUB_FUNCTION(ExpandableStringRelease);
Bob Badour07562132020-05-20 13:18:00 +000032DEFINE_INTERCEPTABLE_STUB_FUNCTION(JNI_CreateJavaVM);
33DEFINE_INTERCEPTABLE_STUB_FUNCTION(JNI_GetCreatedJavaVMs);
34DEFINE_INTERCEPTABLE_STUB_FUNCTION(JNI_GetDefaultJavaVMInitArgs);
Evgeny Eltsin9c7d4622020-07-15 15:30:51 +020035DEFINE_INTERCEPTABLE_STUB_FUNCTION(JniConstants_FileDescriptorClass);
36DEFINE_INTERCEPTABLE_STUB_FUNCTION(JniConstants_FileDescriptor_descriptor);
37DEFINE_INTERCEPTABLE_STUB_FUNCTION(JniConstants_FileDescriptor_init);
38DEFINE_INTERCEPTABLE_STUB_FUNCTION(JniConstants_NIOAccessClass);
39DEFINE_INTERCEPTABLE_STUB_FUNCTION(JniConstants_NIOAccess_getBaseArray);
40DEFINE_INTERCEPTABLE_STUB_FUNCTION(JniConstants_NIOAccess_getBaseArrayOffset);
41DEFINE_INTERCEPTABLE_STUB_FUNCTION(JniConstants_NioBufferClass);
42DEFINE_INTERCEPTABLE_STUB_FUNCTION(JniConstants_NioBuffer__elementSizeShift);
43DEFINE_INTERCEPTABLE_STUB_FUNCTION(JniConstants_NioBuffer_address);
44DEFINE_INTERCEPTABLE_STUB_FUNCTION(JniConstants_NioBuffer_array);
45DEFINE_INTERCEPTABLE_STUB_FUNCTION(JniConstants_NioBuffer_arrayOffset);
46DEFINE_INTERCEPTABLE_STUB_FUNCTION(JniConstants_NioBuffer_limit);
47DEFINE_INTERCEPTABLE_STUB_FUNCTION(JniConstants_NioBuffer_position);
Bob Badour07562132020-05-20 13:18:00 +000048DEFINE_INTERCEPTABLE_STUB_FUNCTION(JniInvocationCreate);
49DEFINE_INTERCEPTABLE_STUB_FUNCTION(JniInvocationDestroy);
50DEFINE_INTERCEPTABLE_STUB_FUNCTION(JniInvocationGetLibrary);
Evgeny Eltsin9c7d4622020-07-15 15:30:51 +020051DEFINE_INTERCEPTABLE_STUB_FUNCTION(JniInvocationGetLibraryWith);
Bob Badour07562132020-05-20 13:18:00 +000052DEFINE_INTERCEPTABLE_STUB_FUNCTION(JniInvocationInit);
Bob Badour07562132020-05-20 13:18:00 +000053DEFINE_INTERCEPTABLE_STUB_FUNCTION(jniCreateFileDescriptor);
54DEFINE_INTERCEPTABLE_STUB_FUNCTION(jniCreateString);
Evgeny Eltsin9c7d4622020-07-15 15:30:51 +020055DEFINE_INTERCEPTABLE_STUB_FUNCTION(jniCreateStringArray);
Bob Badour07562132020-05-20 13:18:00 +000056DEFINE_INTERCEPTABLE_STUB_FUNCTION(jniGetFDFromFileDescriptor);
57DEFINE_INTERCEPTABLE_STUB_FUNCTION(jniGetNioBufferBaseArray);
58DEFINE_INTERCEPTABLE_STUB_FUNCTION(jniGetNioBufferBaseArrayOffset);
59DEFINE_INTERCEPTABLE_STUB_FUNCTION(jniGetNioBufferFields);
60DEFINE_INTERCEPTABLE_STUB_FUNCTION(jniGetNioBufferPointer);
Bob Badour07562132020-05-20 13:18:00 +000061DEFINE_INTERCEPTABLE_STUB_FUNCTION(jniGetReferent);
62DEFINE_INTERCEPTABLE_STUB_FUNCTION(jniLogException);
63DEFINE_INTERCEPTABLE_STUB_FUNCTION(jniRegisterNativeMethods);
64DEFINE_INTERCEPTABLE_STUB_FUNCTION(jniSetFileDescriptorOfFD);
Bob Badour07562132020-05-20 13:18:00 +000065DEFINE_INTERCEPTABLE_STUB_FUNCTION(jniThrowException);
66DEFINE_INTERCEPTABLE_STUB_FUNCTION(jniThrowExceptionFmt);
67DEFINE_INTERCEPTABLE_STUB_FUNCTION(jniThrowIOException);
68DEFINE_INTERCEPTABLE_STUB_FUNCTION(jniThrowNullPointerException);
69DEFINE_INTERCEPTABLE_STUB_FUNCTION(jniThrowRuntimeException);
70DEFINE_INTERCEPTABLE_STUB_FUNCTION(jniUninitializeConstants);
Bob Badour07562132020-05-20 13:18:00 +000071
72static void __attribute__((constructor(0))) init_stub_library() {
Evgeny Eltsin9c7d4622020-07-15 15:30:51 +020073 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);
Bob Badour07562132020-05-20 13:18:00 +000085 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);
Evgeny Eltsin9c7d4622020-07-15 15:30:51 +020088 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);
Bob Badour07562132020-05-20 13:18:00 +0000101 INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", JniInvocationCreate);
102 INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", JniInvocationDestroy);
103 INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", JniInvocationGetLibrary);
Evgeny Eltsin9c7d4622020-07-15 15:30:51 +0200104 INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", JniInvocationGetLibraryWith);
Bob Badour07562132020-05-20 13:18:00 +0000105 INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", JniInvocationInit);
Bob Badour07562132020-05-20 13:18:00 +0000106 INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", jniCreateFileDescriptor);
107 INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", jniCreateString);
Evgeny Eltsin9c7d4622020-07-15 15:30:51 +0200108 INIT_INTERCEPTABLE_STUB_FUNCTION("libnativehelper.so", jniCreateStringArray);
Bob Badour07562132020-05-20 13:18:00 +0000109 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);
Bob Badour07562132020-05-20 13:18:00 +0000114 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);
Bob Badour07562132020-05-20 13:18:00 +0000118 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);
Bob Badour07562132020-05-20 13:18:00 +0000124}
125// clang-format on