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