From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1585 invoked by alias); 24 Oct 2014 14:22:34 -0000 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 Received: (qmail 1565 invoked by uid 89); 24 Oct 2014 14:22:33 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.3 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 24 Oct 2014 14:22:33 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s9OEMUXv031421 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 24 Oct 2014 10:22:31 -0400 Received: from [10.3.113.10] ([10.3.113.10]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s9OEMUY0009221; Fri, 24 Oct 2014 10:22:30 -0400 Message-ID: <544A60A5.4020701@redhat.com> Date: Fri, 24 Oct 2014 14:22:00 -0000 From: "Carlos O'Donell" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.1.0 MIME-Version: 1.0 To: Jan Kratochvil CC: libc-alpha@sourceware.org, gdb-patches@sourceware.org Subject: Re: [libc patch] __tls_get_addr with link_map * instead of modid References: <20141018201540.GA26252@host2.jankratochvil.net> <5449B78E.1060407@redhat.com> <20141024093834.GA24090@host2.jankratochvil.net> In-Reply-To: <20141024093834.GA24090@host2.jankratochvil.net> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit X-SW-Source: 2014-10/txt/msg00641.txt.bz2 On 10/24/2014 05:38 AM, Jan Kratochvil wrote: > On Fri, 24 Oct 2014 04:21:02 +0200, Carlos O'Donell wrote: >> On 10/18/2014 04:15 PM, Jan Kratochvil wrote: >>> Other option suggested by Tom Tromey is implemented by this patch: >>> >>> * A new glibc function like __tls_get_addr that takes a link_map address >>> rather than a module id. >> >> I do not think this is a good solution. >> >> If you use this function in jit'd code, you've now deviated from what normal >> TLS-accessing sequences look like. > > Normal TLS-accessing sequences depend on R_X86_64_DTPMOD64 which the GDB JIT > module cannot depend on. Therefore it will be always deviated. The only purpose of that relocation is to insert the module id once known, thus gdb has to act like a dynamic loader in this respect. What's wrong with using libthread_db to get the module ID and then you can call the normal TLS functions instead of adding to ld's permanent and future ABI and API? > TBH - a bit OT - the whole GDB JIT functionality has many arch specific issues > and deviations due to the initial decision not to use dlopen() for the GDB JIT > module because dlopen() may do some unexpected modifications of the inferior. > I was proposing to simply use dlopen(), Tom Tromey required the mmap(), custom > loading, custom relocations etc. With dlopen() TLS would not be any issue. I don't understand the tradeoffs, but if calling dlopen() in the inferior would have made life easy, then I would have done that first, regardless of the impact on the inferior. Only if users complained or found use cases where things broke would I have fallen back on the "technical purist" solution involving doing everything yourself. Those are decisions that you, as a gdb developer need to make, or reevaluate and make different. What I oppose is the addition to ld's ABI and API something which is not going to be a permanent solution, and for which we can put a function somewhere else and get similar results. The ABI and API for ld is forever, and I change it only with extreme circumspection. >> I don't like libthread_db either, but it avoids us having to put a stop-gap >> API in ld. I say stop-gap because the real solution is going to be to use >> python/DWARF, not any API in ld. >> >> I'm in favour of exactly 3 things: >> >> * New function in libthread_db. >> >> * Heuristics in gdb if libthread_db is not new enough. >> >> * A python or DWARF based parser to replace libthread_db. > > I do not see how libthread_db or its equivalents could be applicable. Isn't a solution to use libthread_db to get the module ID from the link_map, then use that with normal __tls_get_addr instead of adding to ld's API? Please correct me if I'm wrong. > I have attached a use case for GDB JIT to make the problem clear. > Equivalently 'tlsvar' could be placed into a shared library instead of the > main executable. OK. > When the GDB JIT code needs to access 'tlsvar' it already runs independently > from GDB. And inferior does not (and as directed by Tom Tromey above it > should not) dlopen() libthread_db on its own. If gdb knows the link map for tlsvar it can use libthread_db to lookup the module ID, and then when compiling code to access TLS it can call __tls_get_addr? Is that not possible because of something in the JIT? Cheers, Carlos.