summaryrefslogtreecommitdiff
path: root/pcr/qemu-user-static-git/0001-fix-program-invocation-name.patch
diff options
context:
space:
mode:
Diffstat (limited to 'pcr/qemu-user-static-git/0001-fix-program-invocation-name.patch')
-rw-r--r--pcr/qemu-user-static-git/0001-fix-program-invocation-name.patch75
1 files changed, 75 insertions, 0 deletions
diff --git a/pcr/qemu-user-static-git/0001-fix-program-invocation-name.patch b/pcr/qemu-user-static-git/0001-fix-program-invocation-name.patch
new file mode 100644
index 000000000..f2b915b67
--- /dev/null
+++ b/pcr/qemu-user-static-git/0001-fix-program-invocation-name.patch
@@ -0,0 +1,75 @@
+diff --git a/linux-user/main.c b/linux-user/main.c
+index 108e1f202c..30cbb73496 100644
+--- a/linux-user/main.c
++++ b/linux-user/main.c
+@@ -4450,7 +4450,7 @@ static void usage(int exitcode)
+ exit(exitcode);
+ }
+
+-static int parse_args(int argc, char **argv)
++static int parse_args(int argc, char **argv, int assume_P_flag)
+ {
+ const char *r;
+ int optind;
+@@ -4467,6 +4467,19 @@ static int parse_args(int argc, char **argv)
+ }
+ }
+
++ if (assume_P_flag) {
++ /* Assume started by binmisc and binfmt P flag is set */
++ if (argc < 3) {
++ fprintf(stderr, "%s: Please use me through binfmt with P flag\n",
++ argv[0]);
++ exit(1);
++ }
++ filename = argv[1];
++ exec_path = argv[1];
++ /* Next argv must be argv0 for the app */
++ return 2;
++ }
++
+ optind = 1;
+ for (;;) {
+ if (optind >= argc) {
+@@ -4565,7 +4578,8 @@ int main(int argc, char **argv, char **envp)
+
+ qemu_add_opts(&qemu_trace_opts);
+
+- optind = parse_args(argc, argv);
++ execfd = qemu_getauxval(AT_EXECFD);
++ optind = parse_args(argc, argv, execfd > 0);
+
+ if (!trace_init_backends()) {
+ exit(1);
+@@ -4585,7 +4599,6 @@ int main(int argc, char **argv, char **envp)
+
+ init_qemu_uname_release();
+
+- execfd = qemu_getauxval(AT_EXECFD);
+ if (execfd == 0) {
+ execfd = open(filename, O_RDONLY);
+ if (execfd < 0) {
+diff --git a/scripts/qemu-binfmt-conf.sh b/scripts/qemu-binfmt-conf.sh
+index f39ad344fc..d070c33a74 100755
+--- a/scripts/qemu-binfmt-conf.sh
++++ b/scripts/qemu-binfmt-conf.sh
+@@ -292,7 +292,7 @@ SYSTEMDDIR="/etc/binfmt.d"
+ DEBIANDIR="/usr/share/binfmts"
+
+ QEMU_PATH=/usr/local/bin
+-FLAGS=""
++FLAGS="P"
+
+ options=$(getopt -o ds:Q:e:hc: -l debian,systemd:,qemu-path:,exportdir:,help,credential: -- "$@")
+ eval set -- "$options"
+@@ -341,9 +341,7 @@ while true ; do
+ -c|--credential)
+ shift
+ if [ "$1" = "yes" ] ; then
+- FLAGS="OC"
+- else
+- FLAGS=""
++ FLAGS+="OC"
+ fi
+ ;;
+ *)