From 54f7a83a62c27d6da9ee66da1022572d6ea45d84 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Mon, 15 Nov 2021 23:00:04 -0500 Subject: sim: keep track of program environment strings We've been passing the environment strings to sim_create_inferior, but most ports don't do anything with them. A few will use ad-hoc logic to stuff the stack for user-mode programs, but that's it. Let's formalize this across the board by storing the strings in the normal sim state. This will allow (in future commits) supporting more functionality in the run interface, and to unify some of the libgloss syscalls. --- sim/cris/sim-if.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'sim/cris') diff --git a/sim/cris/sim-if.c b/sim/cris/sim-if.c index 500941a..d29ccc5 100644 --- a/sim/cris/sim-if.c +++ b/sim/cris/sim-if.c @@ -951,8 +951,8 @@ sim_open (SIM_OPEN_KIND kind, host_callback *callback, struct bfd *abfd, SIM_RC sim_create_inferior (SIM_DESC sd, struct bfd *abfd, - char * const *argv ATTRIBUTE_UNUSED, - char * const *envp ATTRIBUTE_UNUSED) + char * const *argv, + char * const *env) { SIM_CPU *current_cpu = STATE_CPU (sd, 0); SIM_ADDR addr; @@ -977,6 +977,12 @@ sim_create_inferior (SIM_DESC sd, struct bfd *abfd, STATE_PROG_ARGV (sd) = dupargv (argv); } + if (STATE_PROG_ENVP (sd) != env) + { + freeargv (STATE_PROG_ENVP (sd)); + STATE_PROG_ENVP (sd) = dupargv (env); + } + return SIM_RC_OK; } -- cgit v1.1