Loading...
--- dyld/dyld-45.3/src/dyld.cpp
+++ dyld/dyld-46.12/src/dyld.cpp
@@ -1054,6 +1054,13 @@
return true;
}
break;
+ case CPU_TYPE_X86_64:
+ if ( (cpu_subtype_t)OSSwapBigToHostInt32(archs[i].cpusubtype) == CPU_SUBTYPE_X86_64_ALL ) {
+ *offset = OSSwapBigToHostInt32(archs[i].offset);
+ *len = OSSwapBigToHostInt32(archs[i].size);
+ return true;
+ }
+ break;
}
}
}
@@ -1133,6 +1140,10 @@
if ( mh->cpusubtype == CPU_SUBTYPE_I386_ALL )
return true;
break;
+ case CPU_TYPE_X86_64:
+ if ( mh->cpusubtype == CPU_SUBTYPE_X86_64_ALL )
+ return true;
+ break;
}
}
}
@@ -1694,7 +1705,7 @@
#if __ppc__ || __ppc64__
__asm__ ("trap");
-#elif __i386__
+#elif __i386__ || __x86_64__
__asm__ ("int3");
#else
#error unknown architecture
@@ -1906,21 +1917,16 @@
gLinkContext.apple = apple;
}
-static bool checkEmulation()
-{
-#if __i386__
+static bool isRosetta()
+{
int mib[] = { CTL_KERN, KERN_CLASSIC, getpid() };
int is_classic = 0;
size_t len = sizeof(int);
int ret = sysctl(mib, 3, &is_classic, &len, NULL, 0);
if ((ret != -1) && is_classic) {
- // When a 32-bit ppc program is run under emulation on an Intel processor,
- // we want any i386 dylibs (e.g. the emulator) to not load in the shared region
- // because the shared region is being used by ppc dylibs
- gLinkContext.sharedRegionMode = ImageLoader::kDontUseSharedRegion;
+ // we're running under Rosetta
return true;
}
-#endif
return false;
}
@@ -1982,13 +1988,20 @@
// set pthread keys to dyld range
__pthread_tsd_first = 1;
- bool isEmulated = checkEmulation();
// Pickup the pointer to the exec path.
sExecPath = apple[0];
- if (isEmulated) {
- // under Rosetta
+ bool ignoreEnvironmentVariables = false;
+#if __i386__
+ if ( isRosetta() ) {
+ // under Rosetta (x86 side)
+ // When a 32-bit ppc program is run under emulation on an Intel processor,
+ // we want any i386 dylibs (e.g. any used by Rosetta) to not load in the shared region
+ // because the shared region is being used by ppc dylibs
+ gLinkContext.sharedRegionMode = ImageLoader::kDontUseSharedRegion;
sExecPath = strdup(apple[0] + strlen(apple[0]) + 1);
- }
+ ignoreEnvironmentVariables = true;
+ }
+#endif
if ( sExecPath[0] != '/' ) {
// have relative path, use cwd to make absolute
char cwdbuff[MAXPATHLEN];
@@ -2006,7 +2019,7 @@
if ( issetugid() )
pruneEnvironmentVariables(envp, &apple);
else
- checkEnvironmentVariables(envp, isEmulated);
+ checkEnvironmentVariables(envp, ignoreEnvironmentVariables);
if ( sEnv.DYLD_PRINT_OPTS )
printOptions(argv);
if ( sEnv.DYLD_PRINT_ENV )
@@ -2064,8 +2077,9 @@
fprintf(stderr, "dyld: launch failed\n");
}
+
// Link in any inserted libraries.
- // Do this after link main executable so any extra libraries pulled in by inserted libraries are at end of flat namespace
+ // Do this after linking main executable so any extra libraries pulled in by inserted libraries are at end of flat namespace
if ( insertLibrariesCount > 0 ) {
for (int i=0; i < insertLibrariesCount; ++i) {
try {