Fix dlclose for libraries with thread_local dtors
Introduce new flag to mark soinfo as TLS_NODELETE when
there are thread_local dtors associated with dso_handle
belonging to it.
Test: bionic-unit-tests --gtest_filter=dl*
Test: bionic-unit-tests-glibc --gtest_filter=dl*
Bug: https://github.com/android-ndk/ndk/issues/360
Change-Id: I724ef89fc899788f95c47e6372c38b3313f18fed
diff --git a/linker/linker_soinfo.h b/linker/linker_soinfo.h
index 273c36c..91118b0 100644
--- a/linker/linker_soinfo.h
+++ b/linker/linker_soinfo.h
@@ -52,6 +52,14 @@
// when load group is crossing
// namespace boundary twice and second
// local group depends on the same libraries.
+#define FLAG_TLS_NODELETE 0x00000200 // This flag set when there is at least one
+ // outstanding thread_local dtor
+ // registered with this soinfo. In such
+ // a case the actual unload is
+ // postponed until the last thread_local
+ // destructor associated with this
+ // soinfo is executed and this flag is
+ // unset.
#define FLAG_NEW_SOINFO 0x40000000 // new soinfo format
#define SOINFO_VERSION 3
@@ -253,9 +261,12 @@
void set_linker_flag();
void set_main_executable();
void set_nodelete();
+ void set_tls_nodelete();
+ void unset_tls_nodelete();
size_t increment_ref_count();
size_t decrement_ref_count();
+ size_t get_ref_count() const;
soinfo* get_local_group_root() const;