From 5876f5032f60c45c4bd19e7ea7d0c14d0346b93e Mon Sep 17 00:00:00 2001 From: Jan Kratochvil Date: Wed, 21 May 2014 16:25:53 +0200 Subject: Fix TLS access for -static -pthread I have posted: TLS variables access for -static -lpthread executables https://sourceware.org/ml/libc-help/2014-03/msg00024.html and the GDB patch below has been confirmed as OK for current glibcs. Further work should be done for newer glibcs: Improve TLS variables glibc compatibility https://sourceware.org/bugzilla/show_bug.cgi?id=16954 Still the patch below implements the feature in a fully functional way backward compatible with current glibcs, it depends on the following glibc source line: csu/libc-tls.c main_map->l_tls_modid = 1; gdb/ 2014-05-21 Jan Kratochvil Fix TLS access for -static -pthread. * linux-thread-db.c (struct thread_db_info): Add td_thr_tlsbase_p. (try_thread_db_load_1): Initialize it. (thread_db_get_thread_local_address): Call it if LM is zero. * target.c (target_translate_tls_address): Remove LM_ADDR zero check. * target.h (struct target_ops) (to_get_thread_local_address): Add load_module_addr comment. gdb/gdbserver/ 2014-05-21 Jan Kratochvil Fix TLS access for -static -pthread. * gdbserver/thread-db.c (struct thread_db): Add td_thr_tlsbase_p. (thread_db_get_tls_address): Call it if LOAD_MODULE is zero. (thread_db_load_search, try_thread_db_load_1): Initialize it. gdb/testsuite/ 2014-05-21 Jan Kratochvil Fix TLS access for -static -pthread. * gdb.threads/staticthreads.c (tlsvar): New. (thread_function, main): Initialize it. * gdb.threads/staticthreads.exp: Try gdb_compile_pthreads for $have_tls. Add clean_restart. <$have_tls != "">: Check TLSVAR. Message-ID: <20140410115204.GB16411@host2.jankratochvil.net> --- gdb/target.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'gdb/target.c') diff --git a/gdb/target.c b/gdb/target.c index d08e2ea..71292d3 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -757,10 +757,6 @@ target_translate_tls_address (struct objfile *objfile, CORE_ADDR offset) /* Fetch the load module address for this objfile. */ lm_addr = gdbarch_fetch_tls_load_module_address (target_gdbarch (), objfile); - /* If it's 0, throw the appropriate exception. */ - if (lm_addr == 0) - throw_error (TLS_LOAD_MODULE_NOT_FOUND_ERROR, - _("TLS load module not found")); addr = target->to_get_thread_local_address (target, ptid, lm_addr, offset); -- cgit v1.1