mailing list of musl libc
 help / color / mirror / code / Atom feed
* Question about setting argv[0] when manually using dynamic linker
@ 2017-05-17  0:38 John Regan
  2017-05-17  9:01 ` u-uy74
  0 siblings, 1 reply; 17+ messages in thread
From: John Regan @ 2017-05-17  0:38 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 1273 bytes --]

Hi there - I was wondering if it's possible to somehow set argv[0] when
calling the dynamic linker to load a program.

The reason I want to do this (in case there's a better way) - I was looking
into compiling programs with musl libc, and distributing the binaries with
the needed libc.so file, so I could have a directory structure like:

/bin
|  app
/lib
|  libc.so
|  some_other_lib.so

I can set the rpath to $ORIGIN/../lib so the whole folder is relocatable,
but as far as i know, there's no equivalent concept for setting the dynamic
linker with a path that's relative to the binary.

My current idea is to have a wrapper script, so my structure would be
something like:

/bin
|  app.bin <- actual binary
|  app
/lib
|  libc.so
|  some_other_lib.so

The 'app' script could find the actual, absolute path to itself and figure
out where libc.so is, ending with a line like

exec /path/to/libc.so /path/to/app.bin arg1 arg2 etc

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.

Thanks in advance!!

-John Regan

[-- Attachment #2: Type: text/html, Size: 3013 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2017-07-09 14:04 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-17  0:38 Question about setting argv[0] when manually using dynamic linker John Regan
2017-05-17  9:01 ` u-uy74
2017-05-17 11:00   ` mzpqnxow
2017-05-17 16:07     ` mzpqnxow
2017-05-17 16:16       ` John Regan
2017-05-17 16:24         ` Rich Felker
2017-05-17 19:07           ` u-uy74
2017-05-17 19:16             ` John Regan
2017-05-17 21:10               ` u-uy74
2017-05-17 21:15               ` mzpqnxow
2017-05-17 21:22                 ` John Regan
2017-07-02 17:36           ` u-uy74
2017-07-04 20:58             ` Rich Felker
2017-07-05  6:01               ` u-uy74
2017-07-09  9:23               ` u-uy74
2017-07-09 12:23                 ` Rich Felker
2017-07-09 14:04                   ` u-uy74

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).