From 49489b079a3a2fd42f62c62441981cc734b0d7e7 Mon Sep 17 00:00:00 2001
From: Randy Eckenrode <randy@largeandhighquality.com>
Date: Wed, 13 Nov 2024 13:53:14 -0500
Subject: [PATCH 01/18] Always use `write` instead of `mmap`

This is already required on aarch64-darwin (even under Rosetta 2), so also do it on x86_64-darwin to
avoid needing to use private headers to get the definition of `_COMM_PAGE_CPU_CAPABILITIES64`.
---
 src/ld/OutputFile.cpp | 18 ++----------------
 1 file changed, 2 insertions(+), 16 deletions(-)

diff --git a/src/ld/OutputFile.cpp b/src/ld/OutputFile.cpp
index edefb71..487b338 100644
--- a/src/ld/OutputFile.cpp
+++ b/src/ld/OutputFile.cpp
@@ -57,7 +57,7 @@ extern "C" {
 
 #include <CommonCrypto/CommonDigest.h>
 #include <AvailabilityMacros.h>
-#include <System/machine/cpu_capabilities.h>
+
 
 #include "ExportsTrie.h"
 
@@ -4011,21 +4011,7 @@ void OutputFile::writeOutputFile(ld::Internal& state)
 	}
 
 	// assume mappable by default
-	bool outputIsMappableFile = true;
-
-#if __arm64__
-	// <rdar://problem/66598213> work around VM limitation on Apple Silicon and use write() instead of mmap() to produce output file
-	outputIsMappableFile = false;
-#elif __x86_64__
-#ifndef kIsTranslated
-   #define kIsTranslated  0x4000000000000000ULL
-#endif
-	// <rdar://problem/70505306>
-	bool isTranslated = ((*(uint64_t*)_COMM_PAGE_CPU_CAPABILITIES64) & kIsTranslated);
-	if ( isTranslated ) {
-		outputIsMappableFile = false;
-	}
-#endif
+	bool outputIsMappableFile = false;
 
 	// rdar://107066824 (ld64: provide an environment variable or so to switch to the
 	// allocate+pwrite writing mode (instead of mmap) on Intels)
-- 
2.47.2

