DCL_HOOK_FUNC(static
int
, pthread_attr_setstacksize, void
*
target, size_t size) {
int
res
=
old_pthread_attr_setstacksize((pthread_attr_t
*
) target, size);
LOGV(
"pthread_attr_setstacksize called in [tid, pid]: %d, %d"
, gettid(), getpid());
/
/
Only perform unloading on the main thread
if
(gettid() !
=
getpid())
return
res;
if
(g_hook
-
>should_unmap) {
g_hook
-
>restore_plt_hook();
if
(g_hook
-
>should_unmap) {
void
*
start_addr
=
g_hook
-
>start_addr;
size_t block_size
=
g_hook
-
>block_size;
delete g_hook;
/
/
Because both `pthread_attr_setstacksize`
and
`munmap` have the same function
/
/
signature, we can use `musttail` to let the compiler reuse our stack frame
and
thus
/
/
`munmap` will directly
return
to the caller of `pthread_attr_setstacksize`.
LOGD(
"unmap libzygisk.so loaded at %p with size %zu"
, start_addr, block_size);
[[clang::musttail]]
return
munmap(start_addr, block_size);
}
}
delete g_hook;
return
res;
}