summaryrefslogtreecommitdiff
path: root/src/ldso/dynlink.c
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2014-04-16 12:45:36 -0400
committerRich Felker <dalias@aerifal.cx>2014-04-16 12:45:36 -0400
commitde45164effdddf500756e10e8c6f56b79301d82b (patch)
tree006804924d772ad60cb07c63fa7847725cd7affe /src/ldso/dynlink.c
parentb1ef8067863c52c6af03f623dbecda47204101b1 (diff)
downloadmusl-de45164effdddf500756e10e8c6f56b79301d82b.tar.gz
musl-de45164effdddf500756e10e8c6f56b79301d82b.tar.bz2
musl-de45164effdddf500756e10e8c6f56b79301d82b.tar.xz
musl-de45164effdddf500756e10e8c6f56b79301d82b.zip
add options when explicitly invoking dynamic loader
so far the options are --library-path and --preload which override the corresponding environment variables, and --list which forces the behavior of ldd even if the invocation name is not ldd. both the two-arg form and the one-arg form using an equals sign are supported. based loosely on a patch proposed by Rune.
Diffstat (limited to 'src/ldso/dynlink.c')
-rw-r--r--src/ldso/dynlink.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/ldso/dynlink.c b/src/ldso/dynlink.c
index 1517281a..1cb3fb4c 100644
--- a/src/ldso/dynlink.c
+++ b/src/ldso/dynlink.c
@@ -1055,12 +1055,31 @@ void *__dynlink(int argc, char **argv)
size_t l = strlen(ldname);
if (l >= 3 && !strcmp(ldname+l-3, "ldd")) ldd_mode = 1;
*argv++ = (void *)-1;
- if (argv[0] && !strcmp(argv[0], "--")) *argv++ = (void *)-1;
+ while (argv[0] && argv[0][0]=='-' && argv[0][1]=='-') {
+ char *opt = argv[0]+2;
+ *argv++ = (void *)-1;
+ if (!*opt) {
+ break;
+ } else if (!memcmp(opt, "list", 5)) {
+ ldd_mode = 1;
+ } else if (!memcmp(opt, "library-path", 12)) {
+ if (opt[12]=='=') env_path = opt+13;
+ else if (opt[12]) *argv = 0;
+ else if (*argv) env_path = *argv++;
+ } else if (!memcmp(opt, "preload", 7)) {
+ if (opt[7]=='=') env_preload = opt+8;
+ else if (opt[7]) *argv = 0;
+ else if (*argv) env_preload = *argv++;
+ } else {
+ argv[0] = 0;
+ }
+ argv[-1] = (void *)-1;
+ }
if (!argv[0]) {
dprintf(2, "musl libc\n"
"Version %s\n"
"Dynamic Program Loader\n"
- "Usage: %s [--] pathname%s\n",
+ "Usage: %s [options] [--] pathname%s\n",
__libc_get_version(), ldname,
ldd_mode ? "" : " [args]");
_exit(1);