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(__clone_for_fork);
21 DEFINE_INTERCEPTABLE_STUB_FUNCTION(__get_thread_stack_top);
22 DEFINE_INTERCEPTABLE_STUB_FUNCTION(__pthread_cleanup_pop);
23 DEFINE_INTERCEPTABLE_STUB_FUNCTION(__pthread_cleanup_push);
24 DEFINE_INTERCEPTABLE_STUB_FUNCTION(__system_properties_init);
25 DEFINE_INTERCEPTABLE_STUB_FUNCTION(__system_property_add);
26 DEFINE_INTERCEPTABLE_STUB_FUNCTION(__system_property_area_init);
27 DEFINE_INTERCEPTABLE_STUB_FUNCTION(__system_property_area_serial);
28 DEFINE_INTERCEPTABLE_STUB_FUNCTION(__system_property_find);
29 DEFINE_INTERCEPTABLE_STUB_FUNCTION(__system_property_find_nth);
30 DEFINE_INTERCEPTABLE_STUB_FUNCTION(__system_property_foreach);
31 DEFINE_INTERCEPTABLE_STUB_FUNCTION(__system_property_get);
32 DEFINE_INTERCEPTABLE_STUB_FUNCTION(__system_property_read);
33 DEFINE_INTERCEPTABLE_STUB_FUNCTION(__system_property_read_callback);
34 DEFINE_INTERCEPTABLE_STUB_FUNCTION(__system_property_serial);
35 DEFINE_INTERCEPTABLE_STUB_FUNCTION(__system_property_set);
36 DEFINE_INTERCEPTABLE_STUB_FUNCTION(__system_property_set_filename);
37 DEFINE_INTERCEPTABLE_STUB_FUNCTION(__system_property_update);
38 DEFINE_INTERCEPTABLE_STUB_FUNCTION(__system_property_wait);
39 DEFINE_INTERCEPTABLE_STUB_FUNCTION(__system_property_wait_any);
40 DEFINE_INTERCEPTABLE_STUB_FUNCTION(_longjmp);
41 DEFINE_INTERCEPTABLE_STUB_FUNCTION(_setjmp);
42 DEFINE_INTERCEPTABLE_STUB_FUNCTION(android_getaddrinfofornet);
43 DEFINE_INTERCEPTABLE_STUB_FUNCTION(android_getaddrinfofornetcontext);
44 DEFINE_INTERCEPTABLE_STUB_FUNCTION(android_mallopt);
45 DEFINE_INTERCEPTABLE_STUB_FUNCTION(android_set_abort_message);
46 DEFINE_INTERCEPTABLE_STUB_FUNCTION(freeaddrinfo);
47 DEFINE_INTERCEPTABLE_STUB_FUNCTION(gai_strerror);
48 DEFINE_INTERCEPTABLE_STUB_FUNCTION(getaddrinfo);
49 DEFINE_INTERCEPTABLE_STUB_FUNCTION(gethostbyaddr);
50 DEFINE_INTERCEPTABLE_STUB_FUNCTION(gethostbyname);
51 DEFINE_INTERCEPTABLE_STUB_FUNCTION(getnameinfo);
52 DEFINE_INTERCEPTABLE_STUB_FUNCTION(longjmp);
53 DEFINE_INTERCEPTABLE_STUB_FUNCTION(native_bridge___cxa_thread_atexit_impl);
54 DEFINE_INTERCEPTABLE_STUB_FUNCTION(native_bridge_aligned_alloc);
55 DEFINE_INTERCEPTABLE_STUB_FUNCTION(native_bridge_calloc);
56 DEFINE_INTERCEPTABLE_STUB_FUNCTION(native_bridge_exit);
57 DEFINE_INTERCEPTABLE_STUB_FUNCTION(native_bridge_free);
58 DEFINE_INTERCEPTABLE_STUB_FUNCTION(native_bridge_mallinfo);
59 DEFINE_INTERCEPTABLE_STUB_FUNCTION(native_bridge_malloc);
60 DEFINE_INTERCEPTABLE_STUB_FUNCTION(native_bridge_malloc_disable);
61 DEFINE_INTERCEPTABLE_STUB_FUNCTION(native_bridge_malloc_enable);
62 DEFINE_INTERCEPTABLE_STUB_FUNCTION(native_bridge_malloc_info_helper);
63 DEFINE_INTERCEPTABLE_STUB_FUNCTION(native_bridge_malloc_iterate);
64 DEFINE_INTERCEPTABLE_STUB_FUNCTION(native_bridge_malloc_usable_size);
65 DEFINE_INTERCEPTABLE_STUB_FUNCTION(native_bridge_mallopt);
66 DEFINE_INTERCEPTABLE_STUB_FUNCTION(native_bridge_memalign);
67 DEFINE_INTERCEPTABLE_STUB_FUNCTION(native_bridge_posix_memalign);
68 DEFINE_INTERCEPTABLE_STUB_FUNCTION(native_bridge_pvalloc);
69 DEFINE_INTERCEPTABLE_STUB_FUNCTION(native_bridge_realloc);
70 DEFINE_INTERCEPTABLE_STUB_FUNCTION(native_bridge_valloc);
71 DEFINE_INTERCEPTABLE_STUB_FUNCTION(pthread_attr_destroy);
72 DEFINE_INTERCEPTABLE_STUB_FUNCTION(pthread_attr_getdetachstate);
73 DEFINE_INTERCEPTABLE_STUB_FUNCTION(pthread_attr_getguardsize);
74 DEFINE_INTERCEPTABLE_STUB_FUNCTION(pthread_attr_getinheritsched);
75 DEFINE_INTERCEPTABLE_STUB_FUNCTION(pthread_attr_getschedparam);
76 DEFINE_INTERCEPTABLE_STUB_FUNCTION(pthread_attr_getschedpolicy);
77 DEFINE_INTERCEPTABLE_STUB_FUNCTION(pthread_attr_getscope);
78 DEFINE_INTERCEPTABLE_STUB_FUNCTION(pthread_attr_getstack);
79 DEFINE_INTERCEPTABLE_STUB_FUNCTION(pthread_attr_getstacksize);
80 DEFINE_INTERCEPTABLE_STUB_FUNCTION(pthread_attr_init);
81 DEFINE_INTERCEPTABLE_STUB_FUNCTION(pthread_attr_setdetachstate);
82 DEFINE_INTERCEPTABLE_STUB_FUNCTION(pthread_attr_setguardsize);
83 DEFINE_INTERCEPTABLE_STUB_FUNCTION(pthread_attr_setinheritsched);
84 DEFINE_INTERCEPTABLE_STUB_FUNCTION(pthread_attr_setschedparam);
85 DEFINE_INTERCEPTABLE_STUB_FUNCTION(pthread_attr_setschedpolicy);
86 DEFINE_INTERCEPTABLE_STUB_FUNCTION(pthread_attr_setscope);
87 DEFINE_INTERCEPTABLE_STUB_FUNCTION(pthread_attr_setstack);
88 DEFINE_INTERCEPTABLE_STUB_FUNCTION(pthread_attr_setstacksize);
89 DEFINE_INTERCEPTABLE_STUB_FUNCTION(pthread_create);
90 DEFINE_INTERCEPTABLE_STUB_FUNCTION(pthread_detach);
91 DEFINE_INTERCEPTABLE_STUB_FUNCTION(pthread_exit);
92 DEFINE_INTERCEPTABLE_STUB_FUNCTION(pthread_getattr_np);
93 DEFINE_INTERCEPTABLE_STUB_FUNCTION(pthread_getcpuclockid);
94 DEFINE_INTERCEPTABLE_STUB_FUNCTION(pthread_getname_np);
95 DEFINE_INTERCEPTABLE_STUB_FUNCTION(pthread_getschedparam);
96 DEFINE_INTERCEPTABLE_STUB_FUNCTION(pthread_getspecific);
97 DEFINE_INTERCEPTABLE_STUB_FUNCTION(pthread_gettid_np);
98 DEFINE_INTERCEPTABLE_STUB_FUNCTION(pthread_join);
99 DEFINE_INTERCEPTABLE_STUB_FUNCTION(pthread_key_create);
100 DEFINE_INTERCEPTABLE_STUB_FUNCTION(pthread_key_delete);
101 DEFINE_INTERCEPTABLE_STUB_FUNCTION(pthread_kill);
102 DEFINE_INTERCEPTABLE_STUB_FUNCTION(pthread_setname_np);
103 DEFINE_INTERCEPTABLE_STUB_FUNCTION(pthread_setschedparam);
104 DEFINE_INTERCEPTABLE_STUB_FUNCTION(pthread_setschedprio);
105 DEFINE_INTERCEPTABLE_STUB_FUNCTION(pthread_setspecific);
106 DEFINE_INTERCEPTABLE_STUB_FUNCTION(pthread_sigqueue);
107 DEFINE_INTERCEPTABLE_STUB_FUNCTION(setjmp);
108 DEFINE_INTERCEPTABLE_STUB_FUNCTION(siglongjmp);
109 DEFINE_INTERCEPTABLE_STUB_FUNCTION(sigsetjmp);
110 DEFINE_INTERCEPTABLE_STUB_VARIABLE(environ);
111
init_stub_library()112 static void __attribute__((constructor(0))) init_stub_library() {
113 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", __clone_for_fork);
114 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", __get_thread_stack_top);
115 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", __pthread_cleanup_pop);
116 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", __pthread_cleanup_push);
117 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", __system_properties_init);
118 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", __system_property_add);
119 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", __system_property_area_init);
120 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", __system_property_area_serial);
121 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", __system_property_find);
122 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", __system_property_find_nth);
123 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", __system_property_foreach);
124 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", __system_property_get);
125 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", __system_property_read);
126 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", __system_property_read_callback);
127 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", __system_property_serial);
128 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", __system_property_set);
129 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", __system_property_set_filename);
130 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", __system_property_update);
131 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", __system_property_wait);
132 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", __system_property_wait_any);
133 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", _longjmp);
134 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", _setjmp);
135 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", android_getaddrinfofornet);
136 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", android_getaddrinfofornetcontext);
137 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", android_mallopt);
138 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", android_set_abort_message);
139 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", freeaddrinfo);
140 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", gai_strerror);
141 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", getaddrinfo);
142 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", gethostbyaddr);
143 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", gethostbyname);
144 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", getnameinfo);
145 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", longjmp);
146 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", native_bridge___cxa_thread_atexit_impl);
147 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", native_bridge_aligned_alloc);
148 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", native_bridge_calloc);
149 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", native_bridge_exit);
150 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", native_bridge_free);
151 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", native_bridge_mallinfo);
152 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", native_bridge_malloc);
153 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", native_bridge_malloc_disable);
154 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", native_bridge_malloc_enable);
155 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", native_bridge_malloc_info_helper);
156 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", native_bridge_malloc_iterate);
157 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", native_bridge_malloc_usable_size);
158 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", native_bridge_mallopt);
159 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", native_bridge_memalign);
160 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", native_bridge_posix_memalign);
161 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", native_bridge_pvalloc);
162 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", native_bridge_realloc);
163 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", native_bridge_valloc);
164 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", pthread_attr_destroy);
165 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", pthread_attr_getdetachstate);
166 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", pthread_attr_getguardsize);
167 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", pthread_attr_getinheritsched);
168 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", pthread_attr_getschedparam);
169 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", pthread_attr_getschedpolicy);
170 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", pthread_attr_getscope);
171 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", pthread_attr_getstack);
172 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", pthread_attr_getstacksize);
173 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", pthread_attr_init);
174 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", pthread_attr_setdetachstate);
175 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", pthread_attr_setguardsize);
176 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", pthread_attr_setinheritsched);
177 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", pthread_attr_setschedparam);
178 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", pthread_attr_setschedpolicy);
179 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", pthread_attr_setscope);
180 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", pthread_attr_setstack);
181 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", pthread_attr_setstacksize);
182 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", pthread_create);
183 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", pthread_detach);
184 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", pthread_exit);
185 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", pthread_getattr_np);
186 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", pthread_getcpuclockid);
187 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", pthread_getname_np);
188 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", pthread_getschedparam);
189 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", pthread_getspecific);
190 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", pthread_gettid_np);
191 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", pthread_join);
192 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", pthread_key_create);
193 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", pthread_key_delete);
194 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", pthread_kill);
195 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", pthread_setname_np);
196 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", pthread_setschedparam);
197 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", pthread_setschedprio);
198 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", pthread_setspecific);
199 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", pthread_sigqueue);
200 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", setjmp);
201 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", siglongjmp);
202 INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", sigsetjmp);
203 INIT_INTERCEPTABLE_STUB_VARIABLE("libc.so", environ);
204 }
205 // clang-format on
206