This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] ld.so: add an --argv0 option
- From: Florian Weimer <fw at deneb dot enyo dot de>
- To: libc-alpha at sourceware dot org
- Cc: shenhan at chromium dot org
- Date: Sun, 24 Apr 2016 14:21:27 +0200
- Subject: Re: [PATCH] ld.so: add an --argv0 option
- Authentication-results: sourceware.org; auth=none
- References: <1461389300-29574-1-git-send-email-vapier at gentoo dot org> <87mvokjz1u dot fsf at mid dot deneb dot enyo dot de> <20160423200625 dot GP5369 at vapier dot lan>
* Mike Frysinger:
> On 23 Apr 2016 14:21, Florian Weimer wrote:
>> * Mike Frysinger:
>> > Sometimes when you run a program you want the argv[0] string passed to
>> > the app to be different than the actual path you used to load it. We
>> > can't do this today with invoking via ld.so which can be limiting --
>> > some programs like to inspect their argv[0] and make decisions as to
>> > how it should (re)exec itself or helper tools. For example, clang and
>> > gcc both do argv[0] inspection to support relocatable toolchains.
>>
>> Interesting idea. I think it's sufficiently to include this, but it
>> needs a ChangeLog entry and a test case.
>
> for the test, seems like i'll have to write a small C file that just
> displays its argv, and then another shell script which runs the ldso
> against that simple program and checks the output. unless anyone has
> a simpler idea.
You'll need the shell script wrapper.
Supplying the expected value in another argument, with some prefix and
suffix character, and comparing argv[0] to the extracted orignal
argument, is likely simpler than writing argv[0] to standard output
and reading it back from the shell script.