platform_bionic/libc/arch-common/bionic
Ryan Prichard bcea0e2afd Call __emutls_unregister_key on dlclose
We want to delay the emutls pthread key deletion to keep
__thread/thread_local variables working as long as possible.

Currently, emutls has its own __attribute__((destructor)) function that
deletes its pthread key. That function runs even on process exit, and it
can run before other destructor functions and before C++ static object
destructors.

Move the destructor function to crtbegin_so.c, where an
__attribute__((destructor)) function is only called on dlclose. Use a
priority 0 destructor, which runs after every destructor with a default or
greater priority value.

__emutls_unregister_key will still run before destructor functions of
DT_NEEDED solibs. It also still leaks memory (both the emutls arrays and
each emutls object).

Bug: b/80453944
Test: manual
Change-Id: I6789bcf168415ab8badf2f64687c6a0136c5c917
2018-06-19 13:22:36 -07:00
..
__dso_handle.h Remove an obsolete aarch64 hack. 2017-10-25 10:57:02 -07:00
__dso_handle_so.h Remove an obsolete aarch64 hack. 2017-10-25 10:57:02 -07:00
asm_multiarch.h Properly align init/fini_arrays for crtend.o 2015-05-07 12:56:15 -07:00
atexit.h Fixes for __cxa_finalize 2014-05-05 11:36:57 -07:00
crtbegin.c crtbegin: Correctly align ESP to 16 for __i386__ 2018-02-08 20:55:57 -08:00
crtbegin_so.c Call __emutls_unregister_key on dlclose 2018-06-19 13:22:36 -07:00
crtbrand.S Give ELF notes 4-byte alignment. 2017-12-04 13:21:01 -08:00
crtend.S Properly align init/fini_arrays for crtend.o 2015-05-07 12:56:15 -07:00
crtend_so.S Properly align init/fini_arrays for crtend.o 2015-05-07 12:56:15 -07:00
pthread_atfork.h Add _FORCE_CRT_ATFORK config for crtbegin. 2018-01-24 22:36:31 -08:00