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