TLS variables access for -static -lpthread executables

Jan Kratochvil jan.kratochvil@redhat.com
Sun Mar 30 20:56:00 GMT 2014


On Thu, 27 Mar 2014 19:18:05 +0100, Jan Kratochvil wrote:
> On Thu, 27 Mar 2014 08:45:21 +0100, Carlos O'Donell wrote:
> > The best way forward would be to ensure you can get a link map even for
> > static executables, and then use that with td_thr_tls_get_addr(). This
> > would allow gdb to avoid doing two different things for static and
> > dynamic executables. It also helps all other applications using libthread_db
> > interfaces.
> > 
> > Would you mind testing something like this in fedora rawhide?
> 
> Yes, it works for me.  Just one has to additionally used the attached patch.

Here is the patch I forgot to attach.


> The -static -pthread executable does not have ".dynamic" section so GDB
> thinks the main executable cannot be present in link_map.
> How to fix this compatibility is a topic for upstream GDB, I am not sure how
> the patch is compatible with other SVR4 OSes (like Solaris).


Jan
-------------- next part --------------
diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
index 0da5692..7350edc 100644
--- a/gdb/solib-svr4.c
+++ b/gdb/solib-svr4.c
@@ -1434,9 +1434,11 @@ svr4_current_sos_direct (struct svr4_info *info)
 
   /* Assume that everything is a library if the dynamic loader was loaded
      late by a static executable.  */
+#if 0
   if (exec_bfd && bfd_get_section_by_name (exec_bfd, ".dynamic") == NULL)
     ignore_first = 0;
   else
+#endif
     ignore_first = 1;
 
   back_to = make_cleanup (svr4_free_library_list, &head);


More information about the Libc-help mailing list