Loading...
--- dyld/dyld-46.16/src/dyld.cpp
+++ dyld/dyld-45.3/src/dyld.cpp
@@ -1054,13 +1054,6 @@
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;
}
}
}
@@ -1140,10 +1133,6 @@
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;
}
}
}
@@ -1705,7 +1694,7 @@
#if __ppc__ || __ppc64__
__asm__ ("trap");
-#elif __i386__ || __x86_64__
+#elif __i386__
__asm__ ("int3");
#else
#error unknown architecture
@@ -1917,16 +1906,21 @@
gLinkContext.apple = apple;
}
-static bool isRosetta()
-{
+static bool checkEmulation()
+{
+#if __i386__
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) {
- // we're running under Rosetta
+ // 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;
return true;
}
+#endif
return false;
}
@@ -1988,20 +1982,13 @@
// set pthread keys to dyld range
__pthread_tsd_first = 1;
+ bool isEmulated = checkEmulation();
// Pickup the pointer to the exec path.
sExecPath = apple[0];
- 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;
+ if (isEmulated) {
+ // under Rosetta
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];
@@ -2019,7 +2006,7 @@
if ( issetugid() )
pruneEnvironmentVariables(envp, &apple);
else
- checkEnvironmentVariables(envp, ignoreEnvironmentVariables);
+ checkEnvironmentVariables(envp, isEmulated);
if ( sEnv.DYLD_PRINT_OPTS )
printOptions(argv);
if ( sEnv.DYLD_PRINT_ENV )
@@ -2077,9 +2064,8 @@
fprintf(stderr, "dyld: launch failed\n");
}
-
// Link in any inserted libraries.
- // Do this after linking main executable so any extra libraries pulled in by inserted libraries are at end of flat namespace
+ // Do this after link 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 {