···215215216216 size_t len = strlen(mldr_load_results.envp[i]) + 1;
217217218218- // Don't pass these special env vars down to userland
219219- #define SKIP_VAR(_name) \
218218+ #define ENV_VAR_MATCHES(_name) \
220219 (len > sizeof(_name) - 1 && strncmp(mldr_load_results.envp[i], _name, sizeof(_name) - 1) == 0)
221220221221+ // Don't pass these special env vars down to userland
222222 if (
223223- SKIP_VAR("__mldr_bprefs=") ||
224224- SKIP_VAR("__mldr_sockpath=")
223223+ ENV_VAR_MATCHES("__mldr_bprefs=") ||
224224+ ENV_VAR_MATCHES("__mldr_sockpath=")
225225 ) {
226226 size_t len_after = 0;
227227 const char* orig_envp_i_plus_one = mldr_load_results.envp[i + 1];
···240240 // we have to check this index again because it now points to a different string
241241 --i;
242242 continue;
243243+ }
244244+ // If we were passed __mldr_DYLD_ROOT_PATH, it is a special case of DYLD_ROOT_PATH needing to be set,
245245+ // so we remove the prefix, so dyld reads it as DYLD_ROOT_PATH
246246+ else if (ENV_VAR_MATCHES("__mldr_DYLD_ROOT_PATH=")) {
247247+ const char* env_p = mldr_load_results.envp[i];
248248+ env_p += (sizeof("__mldr_") - 1);
249249+ size_t len_remaining = strlen(env_p) + 1;
250250+ memmove(mldr_load_results.envp[i], env_p, len_remaining);
243251 }
244252 }
245253···519527 sscanf(str, "%i", &lr->lifetime_pipe);
520528 }
521529522522- str = getenv("DYLD_ROOT_PATH");
530530+ str = getenv("__mldr_DYLD_ROOT_PATH");
523531524532 if (str != NULL && lr->root_path == NULL) {
525533 strncpy(root_path, str, sizeof(root_path) - 1);