add: drop soinfo for libzygisk.so

1. fix typo vsdo -> vdso and allow this symbol to be not found, which is the case for the 32bit linkers on some devices
2. use soinfo_free to fully remove the soinfo record of libzygisk.so
3. set `soinfo.size = 0` to avoid the library being unmapped while removing its soinfo record
4. add more debug logs for troubleshooting
This commit is contained in:
JingMatrix
2024-12-15 15:40:40 +01:00
parent 5e43e4a71b
commit b7138d6353
4 changed files with 66 additions and 24 deletions

View File

@@ -185,14 +185,13 @@ DCL_HOOK_FUNC(int, pthread_attr_setstacksize, void *target, size_t size) {
if (gettid() != getpid())
return res;
LOGV("Clean zygisk reminders");
if (should_unmap_zygisk) {
unhook_functions();
if (should_unmap_zygisk) {
// Because both `pthread_attr_setstacksize` and `dlclose` have the same function signature,
// we can use `musttail` to let the compiler reuse our stack frame and thus
// `dlclose` will directly return to the caller of `pthread_attr_setstacksize`.
LOGV("Unmap libzygisk.so");
LOGI("unmap libzygisk.so loaded at %p with size %zu", start_addr, block_size);
[[clang::musttail]] return munmap(start_addr, block_size);
}
}
@@ -584,7 +583,7 @@ void ZygiskContext::run_modules_post() {
m.tryUnload();
}
SoList::DropSoPath("jit-cache");
clean_trace("jit-cache");
// Remap as well to avoid checking of /memfd:jit-cache
for (auto &info : lsplt::MapInfo::Scan()) {
@@ -816,6 +815,11 @@ static void hook_register(dev_t dev, ino_t inode, const char *symbol, void *new_
#define PLT_HOOK_REGISTER(DEV, INODE, NAME) \
PLT_HOOK_REGISTER_SYM(DEV, INODE, #NAME, NAME)
void clean_trace(const char* path) {
LOGD("clean solist trace for path %s", path);
SoList::DropSoPath(path);
}
void hook_functions() {
default_new(plt_hook_list);
default_new(jni_hook_list);