···108108 return -ENOEXEC;
109109 }
110110#endif
111111+ // Modify the argument list so that the dyld name disappears from the process list.
112112+ // The Linux kernel doesn't really support this - it remembers the byte length of the cmdline, which will now decrease.
113113+ // Any app that examines this process' /proc/.../cmdline will from now on see a group of empty arguments after the real arguments.
114114+ // We fix this for NSProcessInfo in libobjcdarwin.
115115+116116+ uintptr_t totalLen = argv[argc-1] + strlen(argv[argc-1]) + 1 - argv[0];
117117+ uintptr_t shortenedLen = totalLen - (strlen(argv[0]) + 1);
111118112112- g_argv = argv+1;
113113- g_argc = argc-1;
119119+ memmove(argv[0], argv[1], shortenedLen);
120120+ memset(argv[0]+shortenedLen, 0, totalLen - shortenedLen);
121121+122122+ // Reconstruct the argv array
123123+ for (int pos = 0, index = 1; index < argc-1; pos++)
124124+ {
125125+ if (!argv[0][pos])
126126+ argv[index++] = &argv[0][pos+1];
127127+ }
128128+129129+ g_argv = argv;
130130+ g_argc = argc;
114131 g_loader = new MachOLoader;
115132116133 autoSysrootSearch();
117134118118- g_loader->run(*g_mainBinary, argc-1, argv+1, envp);
135135+ g_loader->run(*g_mainBinary, argc, argv, envp);
119136120137 delete g_loader;
121138 g_loader = 0;