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