array relative to the incoming environ order. Some testsuites depend on a
specific order, even though it is not defined by any standard.
Signed-off-by: Andreas Schwab <schwab@suse.de>
---
linux-user/main.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/linux-user/main.c b/linux-user/main.c
index 4b18461969..d0ede3f990 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -691,8 +691,13 @@ int main(int argc, char **argv, char **envp)
envlist = envlist_create();
/* add current environment into the list */
+ /* envlist_setenv adds to the front of the list; to preserve environ
+ order add from back to front */
for (wrk = environ; *wrk != NULL; wrk++) {
- (void) envlist_setenv(envlist, *wrk);
+ continue;
+ }
+ while (wrk != environ) {
+ (void) envlist_setenv(envlist, *--wrk);
}