Add secondary counter in place of tls_nodelete flag
The tls_nodelete state should apply to load_group not
isolated soinfo. This actually also means that multiple
soinfos may have tls_counter on their dso_handles.
This change replaces TLS_NODELETE flag with secondary counter.
Note that access to the secondary counter (located inside soinfo)
is pretty expensive because it requires soinfo lookup by dso_handle
whereas dso_handle counter is much faster. This is why it is updated
only when dso_handle counter starts or hits 0.
Bug: http://b/80278285
Test: bionic-unit-tests --gtest_filter=dl*
Change-Id: I535583f6714e45fa2a7eaf7bb3126da20ee7cba9
diff --git a/linker/linker_soinfo.cpp b/linker/linker_soinfo.cpp
index 731e8f5..3191ac7 100644
--- a/linker/linker_soinfo.cpp
+++ b/linker/linker_soinfo.cpp
@@ -537,14 +537,6 @@
rtld_flags_ |= RTLD_NODELETE;
}
-void soinfo::set_tls_nodelete() {
- flags_ |= FLAG_TLS_NODELETE;
-}
-
-void soinfo::unset_tls_nodelete() {
- flags_ &= ~FLAG_TLS_NODELETE;
-}
-
const char* soinfo::get_realpath() const {
#if defined(__work_around_b_24465209__)
if (has_min_version(2)) {
@@ -660,8 +652,7 @@
bool soinfo::can_unload() const {
return !is_linked() ||
(
- (get_rtld_flags() & (RTLD_NODELETE | RTLD_GLOBAL)) == 0 &&
- (flags_ & FLAG_TLS_NODELETE) == 0
+ (get_rtld_flags() & (RTLD_NODELETE | RTLD_GLOBAL)) == 0
);
}