diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2018-07-12 08:29:48 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2018-07-12 08:29:48 +0000 |
commit | 7e22622bdd18c0ac60db437b3c41dc3f94a9c752 (patch) | |
tree | 5c5bc1cd7966f3eaf0a09655a4caaa1424fee57f | |
parent | e2228cb64ae28082e3008628c4133a60d5fc21c7 (diff) | |
parent | ef2dc2dfa4aafc95a2a6aed3b534132f89c8c841 (diff) | |
download | bionic-7e22622bdd18c0ac60db437b3c41dc3f94a9c752.tar.gz |
Merge "Call __emutls_unregister_key on dlclose" into ndk-release-r18ndk-r18bndk-r18-beta2ndk-r18-beta1ndk-release-r18
-rw-r--r-- | libc/arch-common/bionic/crtbegin_so.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/libc/arch-common/bionic/crtbegin_so.c b/libc/arch-common/bionic/crtbegin_so.c index 3754363ab..cf369cc82 100644 --- a/libc/arch-common/bionic/crtbegin_so.c +++ b/libc/arch-common/bionic/crtbegin_so.c @@ -29,11 +29,27 @@ extern void __cxa_finalize(void *); extern void *__dso_handle; -__attribute__((visibility("hidden"),destructor)) -void __on_dlclose() { +__attribute__((destructor)) +static void __on_dlclose(void) { __cxa_finalize(&__dso_handle); } +/* Define a weak stub function here that will be overridden if the solib uses + * emutls. The function needs to be a definition, not just a declaration, + * because gold has a bug where it outputs weak+hidden symbols into the .dynsym + * table. */ +__attribute__((weak,visibility("hidden"))) +void __emutls_unregister_key(void) { +} + +/* Use a priority of 0 to run after any ordinary destructor function. The + * priority setting moves the function towards the front of the .fini_array + * section. */ +__attribute__((destructor(0))) +static void __on_dlclose_late(void) { + __emutls_unregister_key(); +} + /* CRT_LEGACY_WORKAROUND should only be defined when building * this file as part of the platform's C library. * |