Provide guest native_bridge_exit
which is intercepted with host exit.
Bug: 162487409
Test: bionic-unit-tests
Change-Id: I4bacd84f256e80fac2de18f747ec86c075283b88
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/stubs_arm.cpp b/overriding/libc/stubs_arm.cpp
index 1851f1b..1ffa5a9 100644
--- a/overriding/libc/stubs_arm.cpp
+++ b/overriding/libc/stubs_arm.cpp
@@ -45,6 +45,7 @@
DEFINE_INTERCEPTABLE_STUB_FUNCTION(gai_strerror);
DEFINE_INTERCEPTABLE_STUB_FUNCTION(getaddrinfo);
DEFINE_INTERCEPTABLE_STUB_FUNCTION(longjmp);
+DEFINE_INTERCEPTABLE_STUB_FUNCTION(native_bridge_exit);
DEFINE_INTERCEPTABLE_STUB_FUNCTION(pthread_attr_destroy);
DEFINE_INTERCEPTABLE_STUB_FUNCTION(pthread_attr_getdetachstate);
DEFINE_INTERCEPTABLE_STUB_FUNCTION(pthread_attr_getguardsize);
@@ -115,6 +116,7 @@
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_exit);
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..1ffa5a9 100644
--- a/overriding/libc/stubs_arm64.cpp
+++ b/overriding/libc/stubs_arm64.cpp
@@ -45,6 +45,7 @@
DEFINE_INTERCEPTABLE_STUB_FUNCTION(gai_strerror);
DEFINE_INTERCEPTABLE_STUB_FUNCTION(getaddrinfo);
DEFINE_INTERCEPTABLE_STUB_FUNCTION(longjmp);
+DEFINE_INTERCEPTABLE_STUB_FUNCTION(native_bridge_exit);
DEFINE_INTERCEPTABLE_STUB_FUNCTION(pthread_attr_destroy);
DEFINE_INTERCEPTABLE_STUB_FUNCTION(pthread_attr_getdetachstate);
DEFINE_INTERCEPTABLE_STUB_FUNCTION(pthread_attr_getguardsize);
@@ -115,6 +116,7 @@
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_exit);
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);