From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31808 invoked by alias); 6 Aug 2008 11:43:29 -0000 Received: (qmail 31798 invoked by uid 22791); 6 Aug 2008 11:43:28 -0000 X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 06 Aug 2008 11:42:52 +0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id m76Bgopr008455 for ; Wed, 6 Aug 2008 07:42:50 -0400 Received: from pobox.stuttgart.redhat.com (pobox.stuttgart.redhat.com [172.16.2.10]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id m76Bgitr011492 for ; Wed, 6 Aug 2008 07:42:45 -0400 Received: from host0.dyn.jankratochvil.net (sebastian-int.corp.redhat.com [172.16.52.221]) by pobox.stuttgart.redhat.com (8.13.1/8.13.1) with ESMTP id m76BggaV030015 for ; Wed, 6 Aug 2008 07:42:43 -0400 Received: from host0.dyn.jankratochvil.net (localhost [127.0.0.1]) by host0.dyn.jankratochvil.net (8.14.3/8.14.2) with ESMTP id m76BggRn021107; Wed, 6 Aug 2008 13:42:42 +0200 Received: (from jkratoch@localhost) by host0.dyn.jankratochvil.net (8.14.3/8.14.2/Submit) id m76BgfBH021104; Wed, 6 Aug 2008 13:42:41 +0200 Date: Wed, 06 Aug 2008 11:43:00 -0000 From: Jan Kratochvil To: Vinay Sridhar Cc: Daniel Jacobowitz , 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 Message-ID: <20080806114241.GA18923@host0.dyn.jankratochvil.net> References: <1217480020.4755.1.camel@vinaysridhar.in.ibm.com> <20080802171807.GA2755@host0.dyn.jankratochvil.net> <1217925527.3658.41.camel@vinaysridhar.in.ibm.com> <20080805122118.GB17219@caradoc.them.org> <1218021410.13466.4.camel@vinaysridhar.in.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1218021410.13466.4.camel@vinaysridhar.in.ibm.com> User-Agent: Mutt/1.5.18 (2008-05-17) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-08/txt/msg00109.txt.bz2 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