[PATCH] ld.so: add an --argv0 option

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] ld.so: add an --argv0 option

Sourceware - libc-alpha mailing list
Hi,
a few years ago there was an effort for adding --argv0 option:
https://sourceware.org/legacy-ml/libc-alpha/2016-04/msg00576.html.
I made the old patch actual for version 2.31.9000, added a test case and
changelog.

changelog.txt (328 bytes) Download Attachment
argv0.patch (6K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] ld.so: add an --argv0 option

Sourceware - libc-alpha mailing list
* Vincent Mihalkovic via Libc-alpha:

> a few years ago there was an effort for adding --argv0 option:
> https://sourceware.org/legacy-ml/libc-alpha/2016-04/msg00576.html.
> I made the old patch actual for version 2.31.9000, added a test case and
> changelog.

Many shells support “exec -a” to get a similar effect.  The advantage is
that this does not perturb the argument vector layout.  Given that, I
think promoting --argv0 would merely introduce further compatibility
issues.

Thanks,
Florian

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] ld.so: add an --argv0 option

Sourceware - libc-alpha mailing list
Hi,

Sorry, I forgot to CC the libc-alpha mailing-list on my reply.

We do not need the option for shell scripting, where it is indeed not
needed,
as you say.  We are developing a tool for running dynamic analysis tools on
RPM packages fully automatically.  The tool appends custom linker flags
while
executing the %build section of RPMs to make the binaries use our custom ELF
interpreter.  While running the %check section, the interpreter takes care
of
running the binaries built in %build through the selected dynamic analyzer
in
a way that does not break the testing framework.  For this to work, we need
to run dynamic linker explicitly.  There is currently no way to preserve the
original argv[0], which some programs are sensitive to.  This unnecessarily
breaks the tests running in %check of some RPM packages.

An experimental implementation of the custom ELF interpreter is available
here:

    https://github.com/kdudka/cswrap/pull/2

thanks for considering this idea,
vincent mihalkovic

On Wed, Jul 22, 2020 at 11:00 AM Florian Weimer <[hidden email]> wrote:

> * Vincent Mihalkovic via Libc-alpha:
>
> > a few years ago there was an effort for adding --argv0 option:
> > https://sourceware.org/legacy-ml/libc-alpha/2016-04/msg00576.html.
> > I made the old patch actual for version 2.31.9000, added a test case and
> > changelog.
>
> Many shells support “exec -a” to get a similar effect.  The advantage is
> that this does not perturb the argument vector layout.  Given that, I
> think promoting --argv0 would merely introduce further compatibility
> issues.
>
> Thanks,
> Florian
>
>
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] ld.so: add an --argv0 option

Sourceware - libc-alpha mailing list
* Vincent Mihalkovic:

> Sorry, I forgot to CC the libc-alpha mailing-list on my reply.

And I think this won't make it to the list due to the HTML filters, so
here's a full quote:

> We do not need the option for shell scripting, where it is indeed not
> needed, as you say.  We are developing a tool for running dynamic
> analysis tools on RPM packages fully automatically.  The tool appends
> custom linker flags while executing the %build section of RPMs to make
> the binaries use our custom ELF interpreter.  While running the %check
> section, the interpreter takes care of running the binaries built in
> %build through the selected dynamic analyzer in a way that does not
> break the testing framework.  For this to work, we need to run dynamic
> linker explicitly.  There is currently no way to preserve the original
> argv[0], which some programs are sensitive to.  This unnecessarily
> breaks the tests running in %check of some RPM packages.
>
> An experimental implementation of the custom ELF interpreter is available
> here:
>
>     https://github.com/kdudka/cswrap/pull/2
>
> thanks for considering this idea,
> vincent mihalkovic

I was wrong about this, and it is not possible to get the desired
behavior using “exec -a”.  The question remains if just updating the
pointer is sufficient in this context, or if a more elaborate copying
operation is needed to preserve the expected semantics of the argument
vector.

I guest we could add --argv0 now (well, after the 2.32 release), and if
it's incompatible with some applications, we can perhaps tweak it later.

Thanks,
Florian