diff options
author | Alexandre Oliva <oliva@adacore.com> | 2023-12-02 14:14:02 -0300 |
---|---|---|
committer | Alexandre Oliva <oliva@gnu.org> | 2023-12-02 14:14:02 -0300 |
commit | f4dd9416843308d4ae519983415fe62212662536 (patch) | |
tree | d4d8500b2b891371ed0f305b8b59bc8cb7e7d58f | |
parent | 27ce74fa23c93c1189c301993cd19ea766e6bdb5 (diff) | |
download | gcc-f4dd9416843308d4ae519983415fe62212662536.zip gcc-f4dd9416843308d4ae519983415fe62212662536.tar.gz gcc-f4dd9416843308d4ae519983415fe62212662536.tar.bz2 |
libsupc++: try cxa_thread_atexit_impl at runtime
g++.dg/tls/thread_local-order2.C fails when the toolchain is built for
a platform that lacks __cxa_thread_atexit_impl, even if the program is
built and run using that toolchain on a (later) platform that offers
__cxa_thread_atexit_impl.
This patch adds runtime testing for __cxa_thread_atexit_impl on
platforms that support weak symbols.
for libstdc++-v3/ChangeLog
* libsupc++/atexit_thread.cc [__GXX_WEAK__]: Add dynamic
detection of __cxa_thread_atexit_impl.
-rw-r--r-- | libstdc++-v3/libsupc++/atexit_thread.cc | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/libstdc++-v3/libsupc++/atexit_thread.cc b/libstdc++-v3/libsupc++/atexit_thread.cc index 9346d50..cabd7c0 100644 --- a/libstdc++-v3/libsupc++/atexit_thread.cc +++ b/libstdc++-v3/libsupc++/atexit_thread.cc @@ -138,11 +138,24 @@ namespace { } } +#if __GXX_WEAK__ +extern "C" +int __attribute__ ((__weak__)) +__cxa_thread_atexit_impl (void (_GLIBCXX_CDTOR_CALLABI *func) (void *), + void *arg, void *d); +#endif + +// ??? We can't make it an ifunc, can we? extern "C" int __cxxabiv1::__cxa_thread_atexit (void (_GLIBCXX_CDTOR_CALLABI *dtor)(void *), - void *obj, void */*dso_handle*/) + void *obj, void *dso_handle) _GLIBCXX_NOTHROW { +#if __GXX_WEAK__ + if (__cxa_thread_atexit_impl) + return __cxa_thread_atexit_impl (dtor, obj, dso_handle); +#endif + // Do this initialization once. if (__gthread_active_p ()) { |