From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/11335 Path: news.gmane.org!.POSTED!not-for-mail From: mzpqnxow Newsgroups: gmane.linux.lib.musl.general Subject: Re: Question about setting argv[0] when manually using dynamic linker Date: Wed, 17 May 2017 16:07:21 +0000 Message-ID: References: <20170517070115.GL6320@example.net> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="94eb2c054af05760e7054fba7cac" X-Trace: blaine.gmane.org 1495037268 12640 195.159.176.226 (17 May 2017 16:07:48 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 17 May 2017 16:07:48 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-11350-gllmg-musl=m.gmane.org@lists.openwall.com Wed May 17 18:07: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 1dB1UE-0003A6-Fe for gllmg-musl@m.gmane.org; Wed, 17 May 2017 18:07:42 +0200 Original-Received: (qmail 19691 invoked by uid 550); 17 May 2017 16:07:45 -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 19663 invoked from network); 17 May 2017 16:07:44 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mzpqnxow-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=jZhgY3OxSXz1vY3/7Iexuf/W3osKTKKd8QZYidUXb/I=; b=wbRnBO1JmA5Ci9x1KWrGMo3pdt2kKab/EUyRC99zoxi7hZKStYb+boo2nSvpZEpJtR npwE431A0jnWVKU8Q8Svyzr9IGVDDcRgNPl5ChnIU096RKxTGnWHfDsK8ZM9gD9xr1rS rJz5BIFAdG4RaNSgjQG8vlkpdoE3vEO8Gg5I7/wHhh3unpNJT6hdqNx4ytLRN14qPS0B 6+0ioZHKoy+QMSJFIcSy/RjzLjz87u9c7H9hJgucuJcPMSoGHmlRDwSnmnLemGoE8ODR mwyNYoNCl5uagD1PtpUd6Y7GGxutjjc2ELctkylIH1MWfNZ7BXPTEnhatjJsh76NYBLD KpwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=jZhgY3OxSXz1vY3/7Iexuf/W3osKTKKd8QZYidUXb/I=; b=rGx/zcP93mf4H9Tkqu9ZpIso6jYqW4tA91I5zLdeXNY94MAdmw3IK8aSsLBFnmBajD j45Q2HlFCC9Hmh+joP084xsxPOdiOjKhqR4752Syk0DbSYaCBb9leLAVUvkQ/R437S+G MWgLw12F7LAOKswSdm5nHH9tNDl4B5uGPGVAA7o3nqbe/tx4UIsLPqvhmXtQ2b/SYkYt DRhsW1z0a22VdBe5zVaYV/ULmCUflozjzkVrQCPQ5UOCagmie3OvTJO/A0Eonglbfqds whKmgZGD7iyyRDl5NJlSaPrIZy1JhPA+5yxUib6xkw+vKo/mWwVRz7wsaV9fB01Zdpdf xygw== X-Gm-Message-State: AODbwcA0hXTpUYnCeG2v/b0CC9prSF/jmjN48sQjGE5vldL0e6xmjBeM bN0Vs4BEqRPPMMWYyruGX6tBwHL+woMbb5I= X-Received: by 10.55.154.138 with SMTP id c132mr3543715qke.293.1495037252160; Wed, 17 May 2017 09:07:32 -0700 (PDT) In-Reply-To: Xref: news.gmane.org gmane.linux.lib.musl.general:11335 Archived-At: --94eb2c054af05760e7054fba7cac Content-Type: text/plain; charset="UTF-8" BTW, the shell built-in "exec" has -a which can be used to set argv[0] Again though, I'm not entire sure I understand your use, so ignore this if it's irrelevant :> On Wed, May 17, 2017 at 07:00 mzpqnxow wrote: > Is there any reason you want to avoid simply statically linking the > program(s) so that it needs no libc or other shared objects at all? > > Or did I misunderstand what you're trying to do? > > On Wed, May 17, 2017 at 05:05 wrote: > >> On Tue, May 16, 2017 at 08:38:56PM -0400, John Regan wrote: >> > Hi there - I was wondering if it's possible to somehow set argv[0] when >> > calling the dynamic linker to load a program. >> ... >> > I'd like to retain whatever was actually typed on the command line (in >> this >> > case, set argv[0] to "app"), since many apps look at argv[0] to change >> > behavior, ie - gzip vs gunzip. >> > >> > I tried seeing if there was some switch I could pass to the linker, etc >> - >> > as far as I can tell, there's no easy way to do this. >> >> Set argv[0] to whatever you need when you exec*() the dynamic loader, >> which is straightforward with a binary wrapper (not with a shell). >> >> A binary wrapper also adds less overhead then going through a shell. >> >> There is imho hardly any incentive to put such functionalty into the >> loader. I say this even though we are dependent here on such tricks, >> to work around programs which insist on guessing things when not asked to. >> >> Regards, >> Rune >> >> --94eb2c054af05760e7054fba7cac Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
BTW, the shell built-in "exec" has -a which can be used to s= et argv[0]

Again though, I'm not entire sure I= understand your use, so ignore this if it's irrelevant :>

On Wed, May 17, 2017 at 07:00 mzpqnxow= <musl@mzpqnxow.com> wrote:<= br>
Is there any reason you want t= o avoid simply statically linking the program(s) so that it needs no libc o= r other shared objects at all?

Or did I misunderst= and what you're trying to do?

On Wed, May 17, 2017 at 05:05 <u-uy74@aetey.se> wrote:
On Tue, May 16, 2017 at 08:38:56PM -0400, John Rega= n wrote:
> Hi there - I was wondering if it's possible to somehow set argv[0]= when
> calling the dynamic linker to load a program.
=C2=A0...
> I'd like to retain whatever was actually typed on the command line= (in this
> case, set argv[0] to "app"), since many apps look at argv[0]= to change
> behavior, ie - gzip vs gunzip.
>
> I tried seeing if there was some switch I could pass to the linker, et= c -
> as far as I can tell, there's no easy way to do this.

Set argv[0] to whatever you need when you exec*() the dynamic loader,
which is straightforward with a binary wrapper (not with a shell).

A binary wrapper also adds less overhead then going through a shell.

There is imho hardly any incentive to put such functionalty into the
loader. I say this even though we are dependent here on such tricks,
to work around programs which insist on guessing things when not asked to.<= br>
Regards,
Rune

--94eb2c054af05760e7054fba7cac--