From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/2790 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH 2/3] Have different definitions of __pthread_tsd_main agree in size Date: Mon, 11 Feb 2013 16:47:50 -0500 Message-ID: <20130211214750.GT20323@brightrain.aerifal.cx> References: <1360535367.23424.466.camel@eris.loria.fr> <20130211003158.GP20323@brightrain.aerifal.cx> <1360568420.23424.521.camel@eris.loria.fr> <20130211112237.GB6181@port70.net> <20130211120816.GC6181@port70.net> <1360587084.9132.83.camel@eris.loria.fr> <20130211130906.GE6181@port70.net> <1360589888.9132.104.camel@eris.loria.fr> <20130211134454.GR20323@brightrain.aerifal.cx> <1360591648.9132.117.camel@eris.loria.fr> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1360619281 21110 80.91.229.3 (11 Feb 2013 21:48:01 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 11 Feb 2013 21:48:01 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-2791-gllmg-musl=m.gmane.org@lists.openwall.com Mon Feb 11 22:48:23 2013 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1U51Ec-000394-9M for gllmg-musl@plane.gmane.org; Mon, 11 Feb 2013 22:48:22 +0100 Original-Received: (qmail 14327 invoked by uid 550); 11 Feb 2013 21:48:02 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 14319 invoked from network); 11 Feb 2013 21:48:02 -0000 Content-Disposition: inline In-Reply-To: <1360591648.9132.117.camel@eris.loria.fr> User-Agent: Mutt/1.5.21 (2010-09-15) Xref: news.gmane.org gmane.linux.lib.musl.general:2790 Archived-At: On Mon, Feb 11, 2013 at 03:07:28PM +0100, Jens Gustedt wrote: > Am Montag, den 11.02.2013, 08:44 -0500 schrieb Rich Felker: > > The current intended usage is that __environ is used in ISO C > > functions and startup code that must not reference the name environ > > (since it's in the namespace reserved for the application), and POSIX > > and extension functions use environ. > > If this was the intended use, the effective use was not in line with > it. execv and execvp had it differently. > > > There's no reason the latter > > _need_ to use environ though; it was just more convenient and less > > implementation-specific. If you think there's a good reason to change > > it after reading this, let's discuss it. > > With what I have added in my other mail (and you have snipped :) in > the current model there is even the danger that environ and __environ > split into two different objects. > > char **environ; > > int main(void) { > return (long)&environ; > } This is a conforming C program, but not a conforming POSIX program. The current code in musl should allow it to work as long as it does not call functions in the standard library which are not defined by ISO C. If any POSIX functions are used, the program is non-conforming and invokes undefined behavior. With that said, I don't see any reason this behavior is _desirable_ or beneficial, so I'm fine with changing it and always using __environ internally. We could even add a visibility attribute on it so that GOT/PC-relative accesses get used in compilers which support visibility, instead of the more expensive accesses through the GOT. Rich