Module: wine Branch: master Commit: 9ab93415f712c684f1d0cb93945a2518fa060263 URL: https://gitlab.winehq.org/wine/wine/-/commit/9ab93415f712c684f1d0cb93945a251...
Author: Brendan Shanks bshanks@codeweavers.com Date: Tue Nov 29 15:13:09 2022 -0800
loader: In macOS preloader, manually set 'environ' to work around a bug in macOS 12 and later.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=54009
---
loader/preloader_mac.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
diff --git a/loader/preloader_mac.c b/loader/preloader_mac.c index eb0277469a9..bb9336ead2c 100644 --- a/loader/preloader_mac.c +++ b/loader/preloader_mac.c @@ -704,6 +704,22 @@ void *wld_start( void *stack, int *is_unix_thread ) /* decrement argc and "remove" argv[0] */ fixup_stack(stack);
+#if defined(__x86_64__) + /* For LC_UNIXTHREAD binaries on Monterey and later, 'environ' is not set and is NULL. + * Set the correct value here. + */ + if (*is_unix_thread) + { + char **env, ***wine_environ = pdlsym( mod, "environ" ); + + pargc = stack; + argv = (char **)pargc + 1; + env = &argv[*pargc-1] + 2; + + *wine_environ = env; + } +#endif + return entry; }