Snap for 6792403 from 5bd22498a0a645ecfd9301608de002adb7f56534 to rvc-d2-release
Change-Id: I659a38f55ec5e3d0f01c3347120d30780e5f3452
diff --git a/libbinder_ndk/stubs_arm.cc b/libbinder_ndk/stubs_arm.cc
index 75ec784..7b18264 100644
--- a/libbinder_ndk/stubs_arm.cc
+++ b/libbinder_ndk/stubs_arm.cc
@@ -17,8 +17,10 @@
// clang-format off
#include "native_bridge_support/vdso/interceptable_functions.h"
+DEFINE_INTERCEPTABLE_STUB_FUNCTION(ABinderProcess_handlePolledCommands);
DEFINE_INTERCEPTABLE_STUB_FUNCTION(ABinderProcess_joinThreadPool);
DEFINE_INTERCEPTABLE_STUB_FUNCTION(ABinderProcess_setThreadPoolMaxThreadCount);
+DEFINE_INTERCEPTABLE_STUB_FUNCTION(ABinderProcess_setupPolling);
DEFINE_INTERCEPTABLE_STUB_FUNCTION(ABinderProcess_startThreadPool);
DEFINE_INTERCEPTABLE_STUB_FUNCTION(AIBinder_Class_define);
DEFINE_INTERCEPTABLE_STUB_FUNCTION(AIBinder_Class_setHandleShellCommand);
@@ -110,6 +112,9 @@
DEFINE_INTERCEPTABLE_STUB_FUNCTION(AServiceManager_addService);
DEFINE_INTERCEPTABLE_STUB_FUNCTION(AServiceManager_checkService);
DEFINE_INTERCEPTABLE_STUB_FUNCTION(AServiceManager_getService);
+DEFINE_INTERCEPTABLE_STUB_FUNCTION(AServiceManager_isDeclared);
+DEFINE_INTERCEPTABLE_STUB_FUNCTION(AServiceManager_registerLazyService);
+DEFINE_INTERCEPTABLE_STUB_FUNCTION(AServiceManager_waitForService);
DEFINE_INTERCEPTABLE_STUB_FUNCTION(AStatus_delete);
DEFINE_INTERCEPTABLE_STUB_FUNCTION(AStatus_deleteDescription);
DEFINE_INTERCEPTABLE_STUB_FUNCTION(AStatus_fromExceptionCode);
@@ -124,10 +129,14 @@
DEFINE_INTERCEPTABLE_STUB_FUNCTION(AStatus_getStatus);
DEFINE_INTERCEPTABLE_STUB_FUNCTION(AStatus_isOk);
DEFINE_INTERCEPTABLE_STUB_FUNCTION(AStatus_newOk);
+DEFINE_INTERCEPTABLE_STUB_FUNCTION(_Z25AIBinder_toPlatformBinderP8AIBinder);
+DEFINE_INTERCEPTABLE_STUB_FUNCTION(_Z27AIBinder_fromPlatformBinderRKN7android2spINS_7IBinderEEE);
static void __attribute__((constructor(0))) init_stub_library() {
+ INIT_INTERCEPTABLE_STUB_FUNCTION("libbinder_ndk.so", ABinderProcess_handlePolledCommands);
INIT_INTERCEPTABLE_STUB_FUNCTION("libbinder_ndk.so", ABinderProcess_joinThreadPool);
INIT_INTERCEPTABLE_STUB_FUNCTION("libbinder_ndk.so", ABinderProcess_setThreadPoolMaxThreadCount);
+ INIT_INTERCEPTABLE_STUB_FUNCTION("libbinder_ndk.so", ABinderProcess_setupPolling);
INIT_INTERCEPTABLE_STUB_FUNCTION("libbinder_ndk.so", ABinderProcess_startThreadPool);
INIT_INTERCEPTABLE_STUB_FUNCTION("libbinder_ndk.so", AIBinder_Class_define);
INIT_INTERCEPTABLE_STUB_FUNCTION("libbinder_ndk.so", AIBinder_Class_setHandleShellCommand);
@@ -219,6 +228,9 @@
INIT_INTERCEPTABLE_STUB_FUNCTION("libbinder_ndk.so", AServiceManager_addService);
INIT_INTERCEPTABLE_STUB_FUNCTION("libbinder_ndk.so", AServiceManager_checkService);
INIT_INTERCEPTABLE_STUB_FUNCTION("libbinder_ndk.so", AServiceManager_getService);
+ INIT_INTERCEPTABLE_STUB_FUNCTION("libbinder_ndk.so", AServiceManager_isDeclared);
+ INIT_INTERCEPTABLE_STUB_FUNCTION("libbinder_ndk.so", AServiceManager_registerLazyService);
+ INIT_INTERCEPTABLE_STUB_FUNCTION("libbinder_ndk.so", AServiceManager_waitForService);
INIT_INTERCEPTABLE_STUB_FUNCTION("libbinder_ndk.so", AStatus_delete);
INIT_INTERCEPTABLE_STUB_FUNCTION("libbinder_ndk.so", AStatus_deleteDescription);
INIT_INTERCEPTABLE_STUB_FUNCTION("libbinder_ndk.so", AStatus_fromExceptionCode);
@@ -233,5 +245,7 @@
INIT_INTERCEPTABLE_STUB_FUNCTION("libbinder_ndk.so", AStatus_getStatus);
INIT_INTERCEPTABLE_STUB_FUNCTION("libbinder_ndk.so", AStatus_isOk);
INIT_INTERCEPTABLE_STUB_FUNCTION("libbinder_ndk.so", AStatus_newOk);
+ INIT_INTERCEPTABLE_STUB_FUNCTION("libbinder_ndk.so", _Z25AIBinder_toPlatformBinderP8AIBinder);
+ INIT_INTERCEPTABLE_STUB_FUNCTION("libbinder_ndk.so", _Z27AIBinder_fromPlatformBinderRKN7android2spINS_7IBinderEEE);
}
// clang-format on
diff --git a/libbinder_ndk/stubs_arm64.cc b/libbinder_ndk/stubs_arm64.cc
index 75ec784..7b18264 100644
--- a/libbinder_ndk/stubs_arm64.cc
+++ b/libbinder_ndk/stubs_arm64.cc
@@ -17,8 +17,10 @@
// clang-format off
#include "native_bridge_support/vdso/interceptable_functions.h"
+DEFINE_INTERCEPTABLE_STUB_FUNCTION(ABinderProcess_handlePolledCommands);
DEFINE_INTERCEPTABLE_STUB_FUNCTION(ABinderProcess_joinThreadPool);
DEFINE_INTERCEPTABLE_STUB_FUNCTION(ABinderProcess_setThreadPoolMaxThreadCount);
+DEFINE_INTERCEPTABLE_STUB_FUNCTION(ABinderProcess_setupPolling);
DEFINE_INTERCEPTABLE_STUB_FUNCTION(ABinderProcess_startThreadPool);
DEFINE_INTERCEPTABLE_STUB_FUNCTION(AIBinder_Class_define);
DEFINE_INTERCEPTABLE_STUB_FUNCTION(AIBinder_Class_setHandleShellCommand);
@@ -110,6 +112,9 @@
DEFINE_INTERCEPTABLE_STUB_FUNCTION(AServiceManager_addService);
DEFINE_INTERCEPTABLE_STUB_FUNCTION(AServiceManager_checkService);
DEFINE_INTERCEPTABLE_STUB_FUNCTION(AServiceManager_getService);
+DEFINE_INTERCEPTABLE_STUB_FUNCTION(AServiceManager_isDeclared);
+DEFINE_INTERCEPTABLE_STUB_FUNCTION(AServiceManager_registerLazyService);
+DEFINE_INTERCEPTABLE_STUB_FUNCTION(AServiceManager_waitForService);
DEFINE_INTERCEPTABLE_STUB_FUNCTION(AStatus_delete);
DEFINE_INTERCEPTABLE_STUB_FUNCTION(AStatus_deleteDescription);
DEFINE_INTERCEPTABLE_STUB_FUNCTION(AStatus_fromExceptionCode);
@@ -124,10 +129,14 @@
DEFINE_INTERCEPTABLE_STUB_FUNCTION(AStatus_getStatus);
DEFINE_INTERCEPTABLE_STUB_FUNCTION(AStatus_isOk);
DEFINE_INTERCEPTABLE_STUB_FUNCTION(AStatus_newOk);
+DEFINE_INTERCEPTABLE_STUB_FUNCTION(_Z25AIBinder_toPlatformBinderP8AIBinder);
+DEFINE_INTERCEPTABLE_STUB_FUNCTION(_Z27AIBinder_fromPlatformBinderRKN7android2spINS_7IBinderEEE);
static void __attribute__((constructor(0))) init_stub_library() {
+ INIT_INTERCEPTABLE_STUB_FUNCTION("libbinder_ndk.so", ABinderProcess_handlePolledCommands);
INIT_INTERCEPTABLE_STUB_FUNCTION("libbinder_ndk.so", ABinderProcess_joinThreadPool);
INIT_INTERCEPTABLE_STUB_FUNCTION("libbinder_ndk.so", ABinderProcess_setThreadPoolMaxThreadCount);
+ INIT_INTERCEPTABLE_STUB_FUNCTION("libbinder_ndk.so", ABinderProcess_setupPolling);
INIT_INTERCEPTABLE_STUB_FUNCTION("libbinder_ndk.so", ABinderProcess_startThreadPool);
INIT_INTERCEPTABLE_STUB_FUNCTION("libbinder_ndk.so", AIBinder_Class_define);
INIT_INTERCEPTABLE_STUB_FUNCTION("libbinder_ndk.so", AIBinder_Class_setHandleShellCommand);
@@ -219,6 +228,9 @@
INIT_INTERCEPTABLE_STUB_FUNCTION("libbinder_ndk.so", AServiceManager_addService);
INIT_INTERCEPTABLE_STUB_FUNCTION("libbinder_ndk.so", AServiceManager_checkService);
INIT_INTERCEPTABLE_STUB_FUNCTION("libbinder_ndk.so", AServiceManager_getService);
+ INIT_INTERCEPTABLE_STUB_FUNCTION("libbinder_ndk.so", AServiceManager_isDeclared);
+ INIT_INTERCEPTABLE_STUB_FUNCTION("libbinder_ndk.so", AServiceManager_registerLazyService);
+ INIT_INTERCEPTABLE_STUB_FUNCTION("libbinder_ndk.so", AServiceManager_waitForService);
INIT_INTERCEPTABLE_STUB_FUNCTION("libbinder_ndk.so", AStatus_delete);
INIT_INTERCEPTABLE_STUB_FUNCTION("libbinder_ndk.so", AStatus_deleteDescription);
INIT_INTERCEPTABLE_STUB_FUNCTION("libbinder_ndk.so", AStatus_fromExceptionCode);
@@ -233,5 +245,7 @@
INIT_INTERCEPTABLE_STUB_FUNCTION("libbinder_ndk.so", AStatus_getStatus);
INIT_INTERCEPTABLE_STUB_FUNCTION("libbinder_ndk.so", AStatus_isOk);
INIT_INTERCEPTABLE_STUB_FUNCTION("libbinder_ndk.so", AStatus_newOk);
+ INIT_INTERCEPTABLE_STUB_FUNCTION("libbinder_ndk.so", _Z25AIBinder_toPlatformBinderP8AIBinder);
+ INIT_INTERCEPTABLE_STUB_FUNCTION("libbinder_ndk.so", _Z27AIBinder_fromPlatformBinderRKN7android2spINS_7IBinderEEE);
}
// clang-format on
diff --git a/overriding/libc/Android.bp b/overriding/libc/Android.bp
index 1038d8b..ea08fa1 100644
--- a/overriding/libc/Android.bp
+++ b/overriding/libc/Android.bp
@@ -30,7 +30,6 @@
"__cxa_thread_atexit_impl.cpp",
"__libc_add_main_thread.cpp",
"exit.c",
- "fork.cpp",
"malloc_init.cpp",
],
diff --git a/overriding/libc/__cxa_thread_atexit_impl.cpp b/overriding/libc/__cxa_thread_atexit_impl.cpp
index 0e4a099..64af1f5 100644
--- a/overriding/libc/__cxa_thread_atexit_impl.cpp
+++ b/overriding/libc/__cxa_thread_atexit_impl.cpp
@@ -16,11 +16,13 @@
#include <unistd.h>
-#include "native_bridge_support/vdso/vdso.h"
-
extern "C" void __loader_add_thread_local_dtor(void* dso_handle) __attribute__((weak));
extern "C" void __loader_remove_thread_local_dtor(void* dso_handle) __attribute__((weak));
+extern "C" int native_bridge___cxa_thread_atexit_impl(void (*func)(void*),
+ void* arg,
+ void* dso_handle);
+
struct WrappedArg {
typedef void (*thread_atexit_fn_t)(void*);
thread_atexit_fn_t fn;
@@ -53,9 +55,5 @@
__loader_add_thread_local_dtor(dso_handle);
}
- typedef decltype(__cxa_thread_atexit_impl)* fn_t;
- static fn_t __host_cxa_thread_atexit_impl = reinterpret_cast<fn_t>(
- native_bridge_find_proxy_library_symbol("libc.so", "__cxa_thread_atexit_impl"));
-
- return __host_cxa_thread_atexit_impl(WrappedFn, wrapped_arg, dso_handle);
+ return native_bridge___cxa_thread_atexit_impl(WrappedFn, wrapped_arg, dso_handle);
}
diff --git a/overriding/libc/exit.c b/overriding/libc/exit.c
index ce6b438..5ab64be 100644
--- a/overriding/libc/exit.c
+++ b/overriding/libc/exit.c
@@ -16,9 +16,8 @@
#include <unistd.h>
-#include "native_bridge_support/vdso/vdso.h"
-
extern void __cxa_finalize(void* dso_handle);
+extern void native_bridge_exit(int status);
void exit(int status) {
// We don't need to call __cxa_thread_finalize because host "exit" would do that for us.
@@ -29,6 +28,6 @@
// __cxa_finalize() for host objects, of course).
// TODO(b/65052237): Fix that with bionic refactoring?
__cxa_finalize(NULL);
- ((void (*)(int))(native_bridge_find_proxy_library_symbol("libc.so", "exit")))(status);
+ native_bridge_exit(status);
__builtin_unreachable();
}
diff --git a/overriding/libc/fork.cpp b/overriding/libc/fork.cpp
deleted file mode 100644
index aedf248..0000000
--- a/overriding/libc/fork.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (C) 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "native_bridge_support/vdso/vdso.h"
-
-int __clone_for_fork() {
- // Guest fork does pre- and post-clone routines for guest.
- // Call host fork here to do the same for host.
- return ((int (*)())(native_bridge_find_proxy_library_symbol("libc.so", "fork")))();
-}
diff --git a/overriding/libc/malloc_init.cpp b/overriding/libc/malloc_init.cpp
index 76fa5d4..e0fc52e 100644
--- a/overriding/libc/malloc_init.cpp
+++ b/overriding/libc/malloc_init.cpp
@@ -21,10 +21,29 @@
#include <async_safe/log.h>
-#include "native_bridge_support/vdso/vdso.h"
-
#if !defined(LIBC_STATIC)
-static int malloc_info_impl(int options, FILE* fp) {
+extern "C" void* native_bridge_calloc(size_t, size_t);
+extern "C" void native_bridge_free(void*);
+extern "C" struct mallinfo native_bridge_mallinfo();
+extern "C" void* native_bridge_malloc(size_t);
+extern "C" size_t native_bridge_malloc_usable_size(const void*);
+extern "C" void* native_bridge_memalign(size_t, size_t);
+extern "C" int native_bridge_posix_memalign(void**, size_t, size_t);
+extern "C" void* native_bridge_realloc(void*, size_t);
+extern "C" int native_bridge_malloc_iterate(uintptr_t, size_t, void (*)(uintptr_t, size_t, void*), void*);
+extern "C" void native_bridge_malloc_disable();
+extern "C" void native_bridge_malloc_enable();
+extern "C" int native_bridge_mallopt(int, int);
+extern "C" void* native_bridge_aligned_alloc(size_t, size_t);
+
+#if defined(HAVE_DEPRECATED_MALLOC_FUNCS)
+extern "C" void* native_bridge_pvalloc(size_t);
+extern "C" void* native_bridge_valloc(size_t);
+#endif
+
+extern "C" int native_bridge_malloc_info_helper(int options, int fd);
+
+static int native_bridge_malloc_info(int options, FILE* fp) {
// FILE objects cannot cross architecture boundary!
// HACK: extract underlying file descriptor and use it instead.
// TODO(b/146494184): at the moment malloc_info succeeds but writes nothing to memory streams!
@@ -34,42 +53,31 @@
return 0;
}
- typedef int (*fn_t)(int options, int fd);
- static fn_t fn = reinterpret_cast<fn_t>(
- native_bridge_find_proxy_library_symbol("libc.so", "native_bridge_malloc_info"));
- return fn(options, fd);
+ return native_bridge_malloc_info_helper(options, fd);
}
static void malloc_init_impl(libc_globals* globals) {
static const MallocDispatch malloc_default_dispatch __attribute__((unused)) = {
- reinterpret_cast<MallocCalloc>(native_bridge_find_proxy_library_symbol("libc.so", "calloc")),
- reinterpret_cast<MallocFree>(native_bridge_find_proxy_library_symbol("libc.so", "free")),
- reinterpret_cast<MallocMallinfo>(
- native_bridge_find_proxy_library_symbol("libc.so", "mallinfo")),
- reinterpret_cast<MallocMalloc>(native_bridge_find_proxy_library_symbol("libc.so", "malloc")),
- reinterpret_cast<MallocMallocUsableSize>(
- native_bridge_find_proxy_library_symbol("libc.so", "malloc_usable_size")),
- reinterpret_cast<MallocMemalign>(
- native_bridge_find_proxy_library_symbol("libc.so", "memalign")),
- reinterpret_cast<MallocPosixMemalign>(
- native_bridge_find_proxy_library_symbol("libc.so", "posix_memalign")),
+ native_bridge_calloc,
+ native_bridge_free,
+ native_bridge_mallinfo,
+ native_bridge_malloc,
+ native_bridge_malloc_usable_size,
+ native_bridge_memalign,
+ native_bridge_posix_memalign,
#if defined(HAVE_DEPRECATED_MALLOC_FUNCS)
- reinterpret_cast<MallocPvalloc>(native_bridge_find_proxy_library_symbol("libc.so", "pvalloc")),
+ native_bridge_pvalloc,
#endif
- reinterpret_cast<MallocRealloc>(native_bridge_find_proxy_library_symbol("libc.so", "realloc")),
+ native_bridge_realloc,
#if defined(HAVE_DEPRECATED_MALLOC_FUNCS)
- reinterpret_cast<MallocValloc>(native_bridge_find_proxy_library_symbol("libc.so", "valloc")),
+ native_bridge_valloc,
#endif
- reinterpret_cast<MallocIterate>(
- native_bridge_find_proxy_library_symbol("libc.so", "malloc_iterate")),
- reinterpret_cast<MallocMallocDisable>(
- native_bridge_find_proxy_library_symbol("libc.so", "malloc_disable")),
- reinterpret_cast<MallocMallocEnable>(
- native_bridge_find_proxy_library_symbol("libc.so", "malloc_enable")),
- reinterpret_cast<MallocMallopt>(native_bridge_find_proxy_library_symbol("libc.so", "mallopt")),
- reinterpret_cast<MallocAlignedAlloc>(
- native_bridge_find_proxy_library_symbol("libc.so", "aligned_alloc")),
- malloc_info_impl,
+ native_bridge_malloc_iterate,
+ native_bridge_malloc_disable,
+ native_bridge_malloc_enable,
+ native_bridge_mallopt,
+ native_bridge_aligned_alloc,
+ native_bridge_malloc_info,
};
globals->malloc_dispatch_table = malloc_default_dispatch;
globals->current_dispatch_table = &globals->malloc_dispatch_table;
diff --git a/overriding/libc/stubs_arm.cpp b/overriding/libc/stubs_arm.cpp
index 1851f1b..3e6f7ff 100644
--- a/overriding/libc/stubs_arm.cpp
+++ b/overriding/libc/stubs_arm.cpp
@@ -17,6 +17,8 @@
// clang-format off
#include "native_bridge_support/vdso/interceptable_functions.h"
+DEFINE_INTERCEPTABLE_STUB_FUNCTION(__clone_for_fork);
+DEFINE_INTERCEPTABLE_STUB_FUNCTION(__get_thread_stack_top);
DEFINE_INTERCEPTABLE_STUB_FUNCTION(__pthread_cleanup_pop);
DEFINE_INTERCEPTABLE_STUB_FUNCTION(__pthread_cleanup_push);
DEFINE_INTERCEPTABLE_STUB_FUNCTION(__system_properties_init);
@@ -45,6 +47,24 @@
DEFINE_INTERCEPTABLE_STUB_FUNCTION(gai_strerror);
DEFINE_INTERCEPTABLE_STUB_FUNCTION(getaddrinfo);
DEFINE_INTERCEPTABLE_STUB_FUNCTION(longjmp);
+DEFINE_INTERCEPTABLE_STUB_FUNCTION(native_bridge___cxa_thread_atexit_impl);
+DEFINE_INTERCEPTABLE_STUB_FUNCTION(native_bridge_aligned_alloc);
+DEFINE_INTERCEPTABLE_STUB_FUNCTION(native_bridge_calloc);
+DEFINE_INTERCEPTABLE_STUB_FUNCTION(native_bridge_exit);
+DEFINE_INTERCEPTABLE_STUB_FUNCTION(native_bridge_free);
+DEFINE_INTERCEPTABLE_STUB_FUNCTION(native_bridge_mallinfo);
+DEFINE_INTERCEPTABLE_STUB_FUNCTION(native_bridge_malloc);
+DEFINE_INTERCEPTABLE_STUB_FUNCTION(native_bridge_malloc_disable);
+DEFINE_INTERCEPTABLE_STUB_FUNCTION(native_bridge_malloc_enable);
+DEFINE_INTERCEPTABLE_STUB_FUNCTION(native_bridge_malloc_info_helper);
+DEFINE_INTERCEPTABLE_STUB_FUNCTION(native_bridge_malloc_iterate);
+DEFINE_INTERCEPTABLE_STUB_FUNCTION(native_bridge_malloc_usable_size);
+DEFINE_INTERCEPTABLE_STUB_FUNCTION(native_bridge_mallopt);
+DEFINE_INTERCEPTABLE_STUB_FUNCTION(native_bridge_memalign);
+DEFINE_INTERCEPTABLE_STUB_FUNCTION(native_bridge_posix_memalign);
+DEFINE_INTERCEPTABLE_STUB_FUNCTION(native_bridge_pvalloc);
+DEFINE_INTERCEPTABLE_STUB_FUNCTION(native_bridge_realloc);
+DEFINE_INTERCEPTABLE_STUB_FUNCTION(native_bridge_valloc);
DEFINE_INTERCEPTABLE_STUB_FUNCTION(pthread_attr_destroy);
DEFINE_INTERCEPTABLE_STUB_FUNCTION(pthread_attr_getdetachstate);
DEFINE_INTERCEPTABLE_STUB_FUNCTION(pthread_attr_getguardsize);
@@ -87,6 +107,8 @@
DEFINE_INTERCEPTABLE_STUB_VARIABLE(environ);
static void __attribute__((constructor(0))) init_stub_library() {
+ INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", __clone_for_fork);
+ INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", __get_thread_stack_top);
INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", __pthread_cleanup_pop);
INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", __pthread_cleanup_push);
INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", __system_properties_init);
@@ -115,6 +137,24 @@
INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", gai_strerror);
INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", getaddrinfo);
INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", longjmp);
+ INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", native_bridge___cxa_thread_atexit_impl);
+ INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", native_bridge_aligned_alloc);
+ INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", native_bridge_calloc);
+ INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", native_bridge_exit);
+ INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", native_bridge_free);
+ INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", native_bridge_mallinfo);
+ INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", native_bridge_malloc);
+ INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", native_bridge_malloc_disable);
+ INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", native_bridge_malloc_enable);
+ INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", native_bridge_malloc_info_helper);
+ INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", native_bridge_malloc_iterate);
+ INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", native_bridge_malloc_usable_size);
+ INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", native_bridge_mallopt);
+ INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", native_bridge_memalign);
+ INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", native_bridge_posix_memalign);
+ INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", native_bridge_pvalloc);
+ INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", native_bridge_realloc);
+ INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", native_bridge_valloc);
INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", pthread_attr_destroy);
INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", pthread_attr_getdetachstate);
INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", pthread_attr_getguardsize);
diff --git a/overriding/libc/stubs_arm64.cpp b/overriding/libc/stubs_arm64.cpp
index 1851f1b..0a902f8 100644
--- a/overriding/libc/stubs_arm64.cpp
+++ b/overriding/libc/stubs_arm64.cpp
@@ -17,6 +17,8 @@
// clang-format off
#include "native_bridge_support/vdso/interceptable_functions.h"
+DEFINE_INTERCEPTABLE_STUB_FUNCTION(__clone_for_fork);
+DEFINE_INTERCEPTABLE_STUB_FUNCTION(__get_thread_stack_top);
DEFINE_INTERCEPTABLE_STUB_FUNCTION(__pthread_cleanup_pop);
DEFINE_INTERCEPTABLE_STUB_FUNCTION(__pthread_cleanup_push);
DEFINE_INTERCEPTABLE_STUB_FUNCTION(__system_properties_init);
@@ -45,6 +47,22 @@
DEFINE_INTERCEPTABLE_STUB_FUNCTION(gai_strerror);
DEFINE_INTERCEPTABLE_STUB_FUNCTION(getaddrinfo);
DEFINE_INTERCEPTABLE_STUB_FUNCTION(longjmp);
+DEFINE_INTERCEPTABLE_STUB_FUNCTION(native_bridge___cxa_thread_atexit_impl);
+DEFINE_INTERCEPTABLE_STUB_FUNCTION(native_bridge_aligned_alloc);
+DEFINE_INTERCEPTABLE_STUB_FUNCTION(native_bridge_calloc);
+DEFINE_INTERCEPTABLE_STUB_FUNCTION(native_bridge_exit);
+DEFINE_INTERCEPTABLE_STUB_FUNCTION(native_bridge_free);
+DEFINE_INTERCEPTABLE_STUB_FUNCTION(native_bridge_mallinfo);
+DEFINE_INTERCEPTABLE_STUB_FUNCTION(native_bridge_malloc);
+DEFINE_INTERCEPTABLE_STUB_FUNCTION(native_bridge_malloc_disable);
+DEFINE_INTERCEPTABLE_STUB_FUNCTION(native_bridge_malloc_enable);
+DEFINE_INTERCEPTABLE_STUB_FUNCTION(native_bridge_malloc_info_helper);
+DEFINE_INTERCEPTABLE_STUB_FUNCTION(native_bridge_malloc_iterate);
+DEFINE_INTERCEPTABLE_STUB_FUNCTION(native_bridge_malloc_usable_size);
+DEFINE_INTERCEPTABLE_STUB_FUNCTION(native_bridge_mallopt);
+DEFINE_INTERCEPTABLE_STUB_FUNCTION(native_bridge_memalign);
+DEFINE_INTERCEPTABLE_STUB_FUNCTION(native_bridge_posix_memalign);
+DEFINE_INTERCEPTABLE_STUB_FUNCTION(native_bridge_realloc);
DEFINE_INTERCEPTABLE_STUB_FUNCTION(pthread_attr_destroy);
DEFINE_INTERCEPTABLE_STUB_FUNCTION(pthread_attr_getdetachstate);
DEFINE_INTERCEPTABLE_STUB_FUNCTION(pthread_attr_getguardsize);
@@ -87,6 +105,8 @@
DEFINE_INTERCEPTABLE_STUB_VARIABLE(environ);
static void __attribute__((constructor(0))) init_stub_library() {
+ INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", __clone_for_fork);
+ INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", __get_thread_stack_top);
INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", __pthread_cleanup_pop);
INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", __pthread_cleanup_push);
INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", __system_properties_init);
@@ -115,6 +135,22 @@
INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", gai_strerror);
INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", getaddrinfo);
INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", longjmp);
+ INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", native_bridge___cxa_thread_atexit_impl);
+ INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", native_bridge_aligned_alloc);
+ INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", native_bridge_calloc);
+ INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", native_bridge_exit);
+ INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", native_bridge_free);
+ INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", native_bridge_mallinfo);
+ INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", native_bridge_malloc);
+ INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", native_bridge_malloc_disable);
+ INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", native_bridge_malloc_enable);
+ INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", native_bridge_malloc_info_helper);
+ INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", native_bridge_malloc_iterate);
+ INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", native_bridge_malloc_usable_size);
+ INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", native_bridge_mallopt);
+ INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", native_bridge_memalign);
+ INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", native_bridge_posix_memalign);
+ INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", native_bridge_realloc);
INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", pthread_attr_destroy);
INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", pthread_attr_getdetachstate);
INIT_INTERCEPTABLE_STUB_FUNCTION("libc.so", pthread_attr_getguardsize);
diff --git a/vdso/include/native_bridge_support/vdso/interceptable_functions.h b/vdso/include/native_bridge_support/vdso/interceptable_functions.h
index 7532471..2e73af0 100644
--- a/vdso/include/native_bridge_support/vdso/interceptable_functions.h
+++ b/vdso/include/native_bridge_support/vdso/interceptable_functions.h
@@ -23,46 +23,33 @@
#include "native_bridge_support/vdso/vdso.h"
#if defined(__arm__)
-
-#define INTERCEPTABLE_STUB_ASM_CALL(name) \
+#define INTERCEPTABLE_STUB_ASM_FUNCTION(name) \
extern "C" void __attribute((target("arm"), naked)) name() { \
__asm__ __volatile__( \
- "ldr r12, 1f\n" \
- "0: ldr r12, [pc, r12]\n" \
- "bx r12\n" \
- ".p2align 2\n" \
- "1: .long " #name "_var-(0b+8)"); \
+ "ldr r3, =0\n" \
+ "bx r3"); \
}
-
#elif defined(__aarch64__)
-
-#define INTERCEPTABLE_STUB_ASM_CALL(name) \
- extern "C" void __attribute((naked)) name() { \
- __asm__ __volatile__("adrp x8, " #name \
- "_var\n" \
- "ldr x8, [x8, :lo12:" #name \
- "_var]\n" \
- "br x8"); \
+#define INTERCEPTABLE_STUB_ASM_FUNCTION(name) \
+ extern "C" void __attribute((naked)) name() { \
+ __asm__ __volatile__( \
+ "ldr x3, =0\n" \
+ "blr x3"); \
}
-
#else
-
#error Unknown architecture, only arm and aarch64 are supported.
-
#endif
#define DEFINE_INTERCEPTABLE_STUB_VARIABLE(name) uintptr_t name;
#define INIT_INTERCEPTABLE_STUB_VARIABLE(library_name, name) \
- name = \
- *reinterpret_cast<uintptr_t*>(native_bridge_find_proxy_library_symbol(library_name, #name));
+ native_bridge_intercept_symbol(&name, library_name, #name)
-#define DEFINE_INTERCEPTABLE_STUB_FUNCTION(name) \
- extern "C" void name(); \
- static uintptr_t __attribute((used)) name##_var asm(#name "_var"); \
- INTERCEPTABLE_STUB_ASM_CALL(name);
+#define DEFINE_INTERCEPTABLE_STUB_FUNCTION(name) \
+ extern "C" void name(); \
+ INTERCEPTABLE_STUB_ASM_FUNCTION(name)
#define INIT_INTERCEPTABLE_STUB_FUNCTION(library_name, name) \
- name##_var = native_bridge_find_proxy_library_symbol(library_name, #name);
+ native_bridge_intercept_symbol(reinterpret_cast<void*>(name), library_name, #name)
#endif // NATIVE_BRIDGE_SUPPORT_VDSO_INTERCEPTABLE_FUNCTIONS_H_
diff --git a/vdso/include/native_bridge_support/vdso/vdso.h b/vdso/include/native_bridge_support/vdso/vdso.h
index 2d79649..25cee02 100644
--- a/vdso/include/native_bridge_support/vdso/vdso.h
+++ b/vdso/include/native_bridge_support/vdso/vdso.h
@@ -24,7 +24,7 @@
__BEGIN_DECLS
void native_bridge_trace(const char* format, ...);
-uintptr_t native_bridge_find_proxy_library_symbol(const char* library, const char* function);
+void native_bridge_intercept_symbol(void* addr, const char* library, const char* symbol);
void native_bridge_post_init();
__END_DECLS
diff --git a/vdso/vdso_arm.S b/vdso/vdso_arm.S
index 38d3864..11a910b 100644
--- a/vdso/vdso_arm.S
+++ b/vdso/vdso_arm.S
@@ -22,9 +22,9 @@
bx r3
.text
-.globl native_bridge_find_proxy_library_symbol
-.type native_bridge_find_proxy_library_symbol, #function
-native_bridge_find_proxy_library_symbol:
+.globl native_bridge_intercept_symbol
+.type native_bridge_intercept_symbol, #function
+native_bridge_intercept_symbol:
ldr r3, =0
bx r3
diff --git a/vdso/vdso_arm64.S b/vdso/vdso_arm64.S
index 100420c..c6880d3 100644
--- a/vdso/vdso_arm64.S
+++ b/vdso/vdso_arm64.S
@@ -22,9 +22,9 @@
blr x3
.text
-.globl native_bridge_find_proxy_library_symbol
-.type native_bridge_find_proxy_library_symbol, #function
-native_bridge_find_proxy_library_symbol:
+.globl native_bridge_intercept_symbol
+.type native_bridge_intercept_symbol, #function
+native_bridge_intercept_symbol:
ldr x3, =0
blr x3