From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 124758 invoked by alias); 23 May 2019 14:49:53 -0000 Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org Received: (qmail 124700 invoked by uid 89); 23 May 2019 14:49:53 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-5.7 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: simark.ca Received: from simark.ca (HELO simark.ca) (158.69.221.121) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 23 May 2019 14:49:52 +0000 Received: from [172.16.0.120] (192-222-181-218.qc.cable.ebox.net [192.222.181.218]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 6E4921E481; Thu, 23 May 2019 10:49:50 -0400 (EDT) Subject: Re: Getting offset of inital-exec TLS variables on GNU/Linux To: Florian Weimer Cc: gdb@sourceware.org References: <87o941pej8.fsf@oldenburg2.str.redhat.com> <19f008ac-ffb7-5e15-ae6c-5fc00791c964@simark.ca> <87a7flp2tm.fsf@oldenburg2.str.redhat.com> From: Simon Marchi Message-ID: Date: Thu, 23 May 2019 15:55:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <87a7flp2tm.fsf@oldenburg2.str.redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2019-05/txt/msg00041.txt.bz2 On 2019-05-17 10:34 a.m., Florian Weimer wrote: > * Simon Marchi: > >> On 2019-05-17 6:21 a.m., Florian Weimer wrote: >>> Is it possible to obtain the offset of initial-exec TLS variable on >>> GNU/Linux? >>> >>> It doesn't seem so because GDB executes the DWARF to access the TLS >>> variable, so the offset is an implementation detail. Although it is >>> often visible at the ELF layer. >>> >>> Thanks, >>> Florian >> >> Can you clarify a little bit? >> >> You are looking for the offset the variable from which point of reference: >> >> - The start of the TLS area of this module? >> - The start of the TLS area of the current thread? > > The offset from something related to the thread pointer to the variable, > for cases where this is constant (specifically, initial-exec TLS > variables). > >> Also, are you looking for something you can find statically, with just the >> executable, or are you working in the context of the live process? > > I have a live process, and it would be best if the information matched > that process (even if it uses different libraries than those currently > installed in the file system). Hi Florian, I am still a bit unsure of what you are looking for concretely. Are you looking for a GDB command to print this offset? Do you need to compute the offset in an external tool? what information are you starting with? I think that a bit more context would help us help you. GDB uses libthread_db to get the location of TLS variables, which leaves all implementation details about this to glibc. And since you are a glibc maintainer, I am not too sure what I can teach you about this, as you probably know more about this than I do. Simon