From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/11703 Path: news.gmane.org!.POSTED!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: Question about setting argv[0] when manually using dynamic linker Date: Sun, 9 Jul 2017 08:23:25 -0400 Message-ID: <20170709122325.GK1627@brightrain.aerifal.cx> References: <20170517070115.GL6320@example.net> <20170517162428.GH17319@brightrain.aerifal.cx> <20170702173618.GL27260@example.net> <20170704205811.GN1627@brightrain.aerifal.cx> <20170709092322.GA27260@example.net> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1499603028 16560 195.159.176.226 (9 Jul 2017 12:23:48 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 9 Jul 2017 12:23:48 +0000 (UTC) User-Agent: Mutt/1.5.21 (2010-09-15) To: musl@lists.openwall.com Original-X-From: musl-return-11716-gllmg-musl=m.gmane.org@lists.openwall.com Sun Jul 09 14:23:43 2017 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1dUBFQ-0003if-FD for gllmg-musl@m.gmane.org; Sun, 09 Jul 2017 14:23:36 +0200 Original-Received: (qmail 1447 invoked by uid 550); 9 Jul 2017 12:23:37 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 1422 invoked from network); 9 Jul 2017 12:23:37 -0000 Content-Disposition: inline In-Reply-To: <20170709092322.GA27260@example.net> Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:11703 Archived-At: On Sun, Jul 09, 2017 at 11:23:23AM +0200, u-uy74@aetey.se wrote: > On Tue, Jul 04, 2017 at 04:58:11PM -0400, Rich Felker wrote: > > On Sun, Jul 02, 2017 at 07:36:19PM +0200, u-uy74@aetey.se wrote: > > > On Wed, May 17, 2017 at 12:24:28PM -0400, Rich Felker wrote: > > > > Perhaps adding an option like --argv0=foo would be > > > > appropriate. > > > > > > Is this option being considered to introduce? > > > Yes, adding it. > > Thanks again, it makes some "unsolvable" cases work as needed. > > OTOH when applying this in practice, I noticed that a slightly > different behaviour would be very handy: if the linker could > supply its own argv[0] as the one for the program to run. > > This would fit nicely into the framework where we already set argv[0] > anyway, in the same way for both statically and dynamically linked > programs. (The only exception so far would be a hypothetical need to > pass on the value "ldd" as argv[0], then --argv0=ldd would save the day) > > Otherwise we have to set the dynloader --argv0 argument per binary > which is of course possible but remarkably less convenient, > among others because this setting is dynloader-specific, while > otherwise our tools are libc- and dynamic vs static agnostic. > > IOW as long as the loader itself does not rely on its argv[0] > too much, plainly passing on argv[0] is a very practical means to > handle the programs like busybox and gcc transparently. > > What about always passing on the loader argv[0] unless --argv0 is present? > This will not matter for programs which do not analyze argv[0] > and will not make it worse for programs which do. This would be a regression in existing behavior and basically breaks any scripts where the program run wants argv[0] to be its own name. Otherwise I agree it would be a nicer interface. But I don't see any reason your invoking program can't just pass the same string it passes as argv[0] at exec time also as the argument to --argv0. Rich