From owner-freebsd-threads@FreeBSD.ORG Wed Jan 7 04:21:03 2015 Return-Path: Delivered-To: threads@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id AD22E28C; Wed, 7 Jan 2015 04:21:03 +0000 (UTC) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1E8D964054; Wed, 7 Jan 2015 04:21:02 +0000 (UTC) Received: from tom.home (kostik@localhost [127.0.0.1]) by kib.kiev.ua (8.14.9/8.14.9) with ESMTP id t074KsMq070206 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 7 Jan 2015 06:20:54 +0200 (EET) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.9.2 kib.kiev.ua t074KsMq070206 Received: (from kostik@localhost) by tom.home (8.14.9/8.14.9/Submit) id t074KrMN070204; Wed, 7 Jan 2015 06:20:53 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Wed, 7 Jan 2015 06:20:53 +0200 From: Konstantin Belousov To: Daniel Eischen Subject: Re: Fixing dlopen("libpthread.so") Message-ID: <20150107042053.GK42409@kib.kiev.ua> References: <20141226165337.GJ1754@kib.kiev.ua> <20150103212837.GC46373@stack.nl> <20150104114600.GC42409@kib.kiev.ua> <20150104182026.GA61250@stack.nl> <20150105023708.GD42409@kib.kiev.ua> <20150106205046.GA24971@stack.nl> <20150107032941.GJ42409@kib.kiev.ua> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on tom.home Cc: threads@freebsd.org, arch@freebsd.org X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Jan 2015 04:21:03 -0000 On Tue, Jan 06, 2015 at 11:01:30PM -0500, Daniel Eischen wrote: > On Wed, 7 Jan 2015, Konstantin Belousov wrote: > > > On Tue, Jan 06, 2015 at 09:50:46PM +0100, Jilles Tjoelker wrote: > >> On Mon, Jan 05, 2015 at 04:37:08AM +0200, Konstantin Belousov wrote: > >>> Next natural question is about the __error calls through PLT in the > >>> .cerror asm. Before the work was committed, libthr interposed __error, > >>> which was required for correct operation. Now, we need __error exported, > >>> but do we need support its interposing ? This is an implementation > >>> detail for errno, I do not see any loss from not allowing to override > >>> errno location. > >> > >> Indeed, there is no need to allow interposing __error (as with many > >> libc-internal calls to its exported symbols). Additionally, the current > >> namespace.h mechanism could be used to redirect __error calls from C > >> code. > >> > >> Glibc uses macro trickery with the asm labels compiler feature, making > >> libc code see things like > >> int *__error(void) asm("__hidden__error"); > >> and defining the hidden alias somewhere. This also works for > >> compiler-generated calls like to memcpy(). I'm not sure whether it is a > >> good idea to add this extra trickery and depend on the compiler feature. > > I might look at this after the current change is committed. > > I don't quite follow all the above about __error(), but non-C > programs need to interface to an __error() that works regardless > of threading or not. C programs also need to be able to call __error(), to have working errno. Discussion above talks about the need for the programs to be able to interpose __error(), which I and Jilles agree is excessive. My proposal is to remove PLT indirection in the calls to __error() from _inside_ libc, which makes errno functioning in libc both more reliable and slightly faster.