Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: Vinay Sridhar <vinay@linux.vnet.ibm.com>
Cc: Daniel Jacobowitz <drow@false.org>,
	gdb-patches@sources.redhat.com,
	        luisgpm@linux.vnet.ibm.com, uweigand@de.ibm.com
Subject: Re: [patch] Re: Accessing tls variables across files causes a bug
Date: Wed, 06 Aug 2008 11:43:00 -0000	[thread overview]
Message-ID: <20080806114241.GA18923@host0.dyn.jankratochvil.net> (raw)
In-Reply-To: <1218021410.13466.4.camel@vinaysridhar.in.ibm.com>

On Wed, 06 Aug 2008 13:16:50 +0200, Vinay Sridhar wrote:
> On Tue, 2008-08-05 at 08:21 -0400, Daniel Jacobowitz wrote:
> > On Tue, Aug 05, 2008 at 02:08:47PM +0530, Vinay Sridhar wrote:
> > > 2. obtain symbol info from msymtab and check for the section value.
> > > AFAIK, elf has section=17 for tls. 
> > 
> > This number doesn't mean anything.  You want the STT_TLS section type.
> > But if you're doing the right thing without a minimal symbol why rely
> > on a minimal symbol at all?
> > 
> 
> We need to determine that the variable is a "tls" variable. When this is
> extern, the symbol is LOC_UNRESOLVED. So the section type from "sym" is
> not filled. Thats why I tried to determine this from the minimal symbol.

The real problem is that read_var_value() for LOC_UNRESOLVED should return the
address through target_translate_tls_address() while currently it returns only
SYMBOL_VALUE_ADDRESS().  In fact SYMBOL_VALUE_ADDRESS() should call
target_translate_tls_address() but that does not work as it is now being used
both as a getter and setter.  If SYMBOL_VALUE_ADDRESS() should represent only
the raw symbol value (and not the TLS-translated real address) most other GDB
places should use the translated variant instead of SYMBOL_VALUE_ADDRESS().

Another possibility is that LOC_UNRESOLVED may no longer be needed for recent
gcc debuginfos always(?) containting `DW_AT_location's, therefore we would not
have to deal with `minimal_symbol's in this case at all.

> If there is any other method of determining a variable is "tls" before
> its owning symtab is linked in, could you please inform?

You cannot as in the debuginfo the only TLS indication is the presence of
DW_OP_GNU_push_tls_address in the DW_AT_location tag.

For minimal symbols one can query for `minimal_symbol's
	ginfo.bfd_section->flags & SEC_THREAD_LOCAL
, for specific symbols one would have to store the BSF_THREAD_LOCAL flag from
BFD into the GDB structures.  Unaware if STT_TLS symbols are always just in
the SHF_TLS sections.

> On Tue, 2008-08-05 at 08:21 -0400, Daniel Jacobowitz wrote:
> > On Tue, Aug 05, 2008 at 02:08:47PM +0530, Vinay Sridhar wrote:
> > > AFAIK, elf has section=17 for tls. 
> > 
> > This number doesn't mean anything.  You want the STT_TLS section type.

To explain more the Daniel J.'s answer - the order of the sections is very
random and while in this compilation case the STT_TLS section was 17th in the
sections list in other compilations it will get a different number.

Section Headers:
  [Nr] Name              Type             Address           Offset
       Size              EntSize          Flags  Link  Info  Align
  [18] .tbss             NOBITS           0000000000600754  00000754
       0000000000000005  0000000000000000 WAT       0     0     4
(Flags=T)



Regards,
Jan


  parent reply	other threads:[~2008-08-06 11:43 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1217480020.4755.1.camel@vinaysridhar.in.ibm.com>
2008-08-02 17:18 ` Jan Kratochvil
2008-08-04 19:36   ` Luis Machado
2008-08-05 13:26     ` [patch] Finish removing <bug-gdb@prep.ai.mit.edu> (PR gdb/1543) Jan Kratochvil
2008-08-06 12:13       ` Daniel Jacobowitz
2008-08-04 19:40   ` [patch] Re: Accessing tls variables across files causes a bug Ulrich Weigand
2008-08-05  8:39   ` Vinay Sridhar
2008-08-05 12:22     ` Daniel Jacobowitz
2008-08-06 11:16       ` Vinay Sridhar
2008-08-06 11:25         ` Daniel Jacobowitz
2008-08-06 11:43         ` Jan Kratochvil [this message]
2008-08-06 15:20           ` Jan Kratochvil
2008-08-27  4:37             ` Vinay Sridhar
2009-06-12 17:06             ` [resolved] " Jan Kratochvil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080806114241.GA18923@host0.dyn.jankratochvil.net \
    --to=jan.kratochvil@redhat.com \
    --cc=drow@false.org \
    --cc=gdb-patches@sources.redhat.com \
    --cc=luisgpm@linux.vnet.ibm.com \
    --cc=uweigand@de.ibm.com \
    --cc=vinay@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox