Move dlerror out of a TLS slot and into a pthread_internal_t member.
Bug: N/A
Test: boots, tests pass.
Change-Id: Idf25d2ee457a5d26d0bdd6281cee72c345c8b755
diff --git a/linker/dlfcn.cpp b/linker/dlfcn.cpp
index 5ae7b9b..5a47272 100644
--- a/linker/dlfcn.cpp
+++ b/linker/dlfcn.cpp
@@ -96,10 +96,9 @@
static pthread_mutex_t g_dl_mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
static char* __bionic_set_dlerror(char* new_value) {
- char** dlerror_slot = &reinterpret_cast<char**>(__get_tls())[TLS_SLOT_DLERROR];
+ char* old_value = __get_thread()->current_dlerror;
+ __get_thread()->current_dlerror = new_value;
- char* old_value = *dlerror_slot;
- *dlerror_slot = new_value;
if (new_value != nullptr) LD_LOG(kLogErrors, "dlerror set to \"%s\"", new_value);
return old_value;
}