[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 41/42] bsd-user: Add '-0 argv0' option to bsd-user/main.c
From: |
imp |
Subject: |
[PULL 41/42] bsd-user: Add '-0 argv0' option to bsd-user/main.c |
Date: |
Tue, 7 Sep 2021 15:53:31 -0600 |
From: Colin Percival <cperciva@tarsnap.com>
Previously it was impossible to emulate a program with a file name
different from its argv[0]. With this change, you can run
qemu -0 fakename realname args
which runs the program "realname" with an argv of "fakename args".
Signed-off-by: Colin Percival <cperciva@tarsnap.com>
Signed-off-by: Warner Losh <imp@bsdimp.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
bsd-user/main.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/bsd-user/main.c b/bsd-user/main.c
index 659dd2b512..6df4f4f011 100644
--- a/bsd-user/main.c
+++ b/bsd-user/main.c
@@ -243,6 +243,7 @@ int main(int argc, char **argv)
char **target_environ, **wrk;
envlist_t *envlist = NULL;
bsd_type = HOST_DEFAULT_BSD_TYPE;
+ char *argv0 = NULL;
adjust_ssize();
@@ -367,6 +368,8 @@ int main(int argc, char **argv)
do_strace = 1;
} else if (!strcmp(r, "trace")) {
trace_opt_parse(optarg);
+ } else if (!strcmp(r, "0")) {
+ argv0 = argv[optind++];
} else {
usage();
}
@@ -390,6 +393,9 @@ int main(int argc, char **argv)
usage();
}
filename = argv[optind];
+ if (argv0) {
+ argv[optind] = argv0;
+ }
if (!trace_init_backends()) {
exit(1);
--
2.32.0
- [PULL 24/42] bsd-user: Create target specific vmparam.h, (continued)
- [PULL 24/42] bsd-user: Create target specific vmparam.h, imp, 2021/09/07
- [PULL 20/42] bsd-user: Move per-cpu code into target_arch_cpu.h, imp, 2021/09/07
- [PULL 31/42] bsd-user: Remove dead #ifdefs from elfload.c, imp, 2021/09/07
- [PULL 33/42] bsd-user: update debugging in mmap.c, imp, 2021/09/07
- [PULL 36/42] bsd-user: add stubbed out core dump support, imp, 2021/09/07
- [PULL 35/42] bsd-user: Add target_os_user.h to capture the user/kernel structures, imp, 2021/09/07
- [PULL 39/42] bsd-user: move gemu_log to later in the file, imp, 2021/09/07
- [PULL 34/42] bsd-user: Add target_arch_reg to describe a target's register set, imp, 2021/09/07
- [PULL 38/42] bsd-user: Refactor load_elf_sections and is_target_elf_binary, imp, 2021/09/07
- [PULL 40/42] bsd-user: Implement interlock for atomic operations, imp, 2021/09/07
- [PULL 41/42] bsd-user: Add '-0 argv0' option to bsd-user/main.c,
imp <=
- [PULL 37/42] bsd-user: elfload.c style catch up patch, imp, 2021/09/07
- [PULL 28/42] bsd-user: Move stack initializtion into a per-os file., imp, 2021/09/07
- [PULL 42/42] bsd-user: Update mapping to handle reserved and starting conditions, imp, 2021/09/07
- Re: [PULL 00/42] bsd-user updates to run hello world, Peter Maydell, 2021/09/09
- Re: [PULL 00/42] bsd-user updates to run hello world, Philippe Mathieu-Daudé, 2021/09/09