This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] Re: Accessing tls variables across files causes a bug


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]