aboutsummaryrefslogtreecommitdiffstats
path: root/main/musl/0054-allow-specifying-argv-0-when-invoking-a-program-via-.patch
diff options
context:
space:
mode:
Diffstat (limited to 'main/musl/0054-allow-specifying-argv-0-when-invoking-a-program-via-.patch')
-rw-r--r--main/musl/0054-allow-specifying-argv-0-when-invoking-a-program-via-.patch48
1 files changed, 48 insertions, 0 deletions
diff --git a/main/musl/0054-allow-specifying-argv-0-when-invoking-a-program-via-.patch b/main/musl/0054-allow-specifying-argv-0-when-invoking-a-program-via-.patch
new file mode 100644
index 0000000000..9855ac7778
--- /dev/null
+++ b/main/musl/0054-allow-specifying-argv-0-when-invoking-a-program-via-.patch
@@ -0,0 +1,48 @@
+From f3055e0163aad1cebb0867078643b36643c5d95f Mon Sep 17 00:00:00 2001
+From: Rich Felker <dalias@aerifal.cx>
+Date: Tue, 4 Jul 2017 16:58:28 -0400
+Subject: [PATCH 54/54] allow specifying argv[0] when invoking a program via
+ ldso command
+
+previously, the pathname used to load the program was always used as
+argv[0]. the default remains the same, but a new --argv0 option can be
+used to provide a different value.
+---
+ ldso/dynlink.c | 7 +++++++
+ 1 file changed, 7 insertions(+)
+
+diff --git a/ldso/dynlink.c b/ldso/dynlink.c
+index fc6a68b8..35a90aef 100644
+--- a/ldso/dynlink.c
++++ b/ldso/dynlink.c
+@@ -1437,6 +1437,7 @@ _Noreturn void __dls3(size_t *sp)
+ size_t aux[AUX_CNT], *auxv;
+ size_t i;
+ char *env_preload=0;
++ char *replace_argv0=0;
+ size_t vdso_base;
+ int argc = *sp;
+ char **argv = (void *)(sp+1);
+@@ -1521,6 +1522,10 @@ _Noreturn void __dls3(size_t *sp)
+ if (opt[7]=='=') env_preload = opt+8;
+ else if (opt[7]) *argv = 0;
+ else if (*argv) env_preload = *argv++;
++ } else if (!memcmp(opt, "argv0", 5)) {
++ if (opt[5]=='=') replace_argv0 = opt+6;
++ else if (opt[5]) *argv = 0;
++ else if (*argv) replace_argv0 = *argv++;
+ } else {
+ argv[0] = 0;
+ }
+@@ -1677,6 +1682,8 @@ _Noreturn void __dls3(size_t *sp)
+ debug.state = 0;
+ _dl_debug_state();
+
++ if (replace_argv0) argv[0] = replace_argv0;
++
+ errno = 0;
+
+ CRTJMP((void *)aux[AT_ENTRY], argv-1);
+--
+2.13.1
+