Loading...
mach_o/Platform.cpp dyld-1122.1 dyld-1340
--- dyld/dyld-1122.1/mach_o/Platform.cpp
+++ dyld/dyld-1340/mach_o/Platform.cpp
@@ -34,13 +34,12 @@
 #include "Platform.h"
 #include "Architecture.h"
 
-
-#ifndef PLATFORM_FIRMWARE
-  #define PLATFORM_FIRMWARE 13
-#endif
-
-#ifndef PLATFORM_SEPOS
-  #define PLATFORM_SEPOS 14
+#ifndef PLATFORM_VISIONOS
+  #define PLATFORM_VISIONOS 11
+#endif
+
+#ifndef PLATFORM_VISIONOSSIMULATOR
+  #define PLATFORM_VISIONOSSIMULATOR 12
 #endif
 
 #ifndef PLATFORM_MACOS_EXCLAVECORE
@@ -74,6 +73,15 @@
 #ifndef PLATFORM_WATCHOS_EXCLAVEKIT
   #define PLATFORM_WATCHOS_EXCLAVEKIT 22
 #endif
+
+#ifndef PLATFORM_VISIONOS_EXCLAVECORE
+  #define PLATFORM_VISIONOS_EXCLAVECORE 23
+#endif
+
+#ifndef PLATFORM_VISIONOS_EXCLAVEKIT
+  #define PLATFORM_VISIONOS_EXCLAVEKIT 24
+#endif
+
 
 
 namespace mach_o {
@@ -84,17 +92,23 @@
 //
 
 constinit const Platform::Epoch Platform::Epoch::invalid(0);
+constinit const Platform::Epoch Platform::Epoch::fall2012(2012);
+constinit const Platform::Epoch Platform::Epoch::fall2013(2013);
 constinit const Platform::Epoch Platform::Epoch::fall2015(2015);
 constinit const Platform::Epoch Platform::Epoch::fall2016(2016);
 constinit const Platform::Epoch Platform::Epoch::fall2017(2017);
 constinit const Platform::Epoch Platform::Epoch::fall2018(2018);
 constinit const Platform::Epoch Platform::Epoch::fall2019(2019);
+constinit const Platform::Epoch Platform::Epoch::spring2020(2020, true);
 constinit const Platform::Epoch Platform::Epoch::fall2020(2020);
 constinit const Platform::Epoch Platform::Epoch::fall2021(2021);
 constinit const Platform::Epoch Platform::Epoch::spring2021(2021, true);
 constinit const Platform::Epoch Platform::Epoch::fall2022(2022);
 constinit const Platform::Epoch Platform::Epoch::fall2023(2023);
+constinit const Platform::Epoch Platform::Epoch::spring2024(2024, true);
 constinit const Platform::Epoch Platform::Epoch::fall2024(2024);
+constinit const Platform::Epoch Platform::Epoch::spring2025(2025, true);
+constinit const Platform::Epoch Platform::Epoch::fall2025(2025);
 
 
 
@@ -108,23 +122,23 @@
  * @abstract
  *      Implementation details for Platform.
  */
-class PlatformInfo
-{
-public:
-    consteval PlatformInfo(uint32_t v, CString nm, bool isSim, bool fp, uint16_t year, CString altName = {})
-                             : value(v), name(nm), altName(altName), isSimulator(isSim),supportsFairPlayEncryption(fp), baseYear(year) { }
-
-    uint32_t            value;
+class VIS_HIDDEN PlatformInfo
+{
+public:
+    consteval PlatformInfo(uint32_t v, CString nm, bool isSim, bool fp, bool alignedIn2025, uint16_t year, const PlatformInfo* info, CString altName = {})
+        : basePlatformInfo(info), name(nm), altName(altName), value(v), baseYear(year),
+          isSimulator(isSim), supportsFairPlayEncryption(fp), wasAlignedIn2025(alignedIn2025) { }
+
+    const PlatformInfo* basePlatformInfo;
     CString             name;
     CString             altName;
+    uint32_t            value;
+    uint16_t            baseYear;    // year 1.0 shipped
     bool                isSimulator;
+    bool                isExclaveCore=false;
+    bool                isExclaveKit=false;
     bool                supportsFairPlayEncryption;
-    uint16_t            baseYear;    // year 1.0 shipped
-
-    // Epoch is private to Platform and PlatformInfo, so convert to year/spring of use by subclasses
-    Version32 versionForEpoch(Platform::Epoch e) const {
-        return versionForYear(e.year(), e.isSpring());
-    }
+    bool                wasAlignedIn2025;           // was this platform bumped to version 26.0 in fall 2025?
 
     // Epoch is private to Platform and PlatformInfo, so convert to year/spring of use by subclasses
     Platform::Epoch epochForVersion(Version32 vers) const {
@@ -134,11 +148,12 @@
         return Platform::Epoch(year, spring);
     }
 
-    virtual Version32 versionForYear(uint16_t year, bool spring) const {
-        return majorVersionFromBaseYear(year, spring);
-    }
     virtual void yearForVersion(Version32 vers, uint16_t& year, bool& spring) const {
         yearForMajorVersion(vers, year, spring);
+    }
+    virtual uint16_t minorVersionForSpring(uint16_t major) const {
+        // most spring releses are X.4
+        return 4;
     }
 
 
@@ -146,58 +161,44 @@
     friend class Platform;
     static constinit const PlatformInfo* knownPlatformInfos[];
 
-    // version bumped by 1.0 each Fall, started at baseYear
-    Version32 majorVersionFromBaseYear(uint16_t year, bool spring) const {
-        unsigned major = year - baseYear;
-        uint16_t minor = 0;
-        if ( spring ) {
-            --major;
-            minor = 4;
-        }
-        return Version32(major, minor);
-    }
-
-    // version bumped by 0.1 each Fall
-    Version32 tenVersionFromBaseYear(uint16_t year, bool spring, uint16_t tenBaseYear) const {
-        // version is 10.xx
-        uint16_t subVersion = year - tenBaseYear;
-        uint8_t  dot        = 0;
-        if ( spring ) {
-            --subVersion;
-            dot = 4;
-        }
-        return Version32(10, subVersion, dot);
-    }
-
     void yearForMajorVersion(Version32 vers, uint16_t& year, bool& spring) const {
         // version is >= 11.0
-        year = baseYear + (vers.value() >> 16);
-        spring = ((vers.value() & 0x000000FF) >= 0x00000300);
+
+        // In 2025, many platform aligned on version 26
+        if ( wasAlignedIn2025 ) {
+            if ( vers.major() >= 26 ) {
+                year = 2000 + (vers.major() - 1);
+            } else {
+                // clamp anything in the gap to 26
+                year = baseYear + vers.major();
+                if ( year > 2026 )
+                    year = 2026;
+            }
+        } else {
+            year = baseYear + vers.major();
+        }
+
+        spring = (vers.minor() >= minorVersionForSpring(vers.major()));
+        // Say the 2023 fall release has the year 2023, then we want the following spring release,
+        // what availability calls 2023(e) to actually be in calendar year 2024
         if ( spring )
-            --year;
+            ++year;
     }
 
     void yearForTenMinorVersion(Version32 vers, uint16_t tenBaseYear, uint16_t& year, bool& spring) const {
         // version is 10.x
         year = tenBaseYear + ((vers.value() - 0x000A0000) >> 8);
-        spring = ((vers.value() & 0x000000FF) >= 0x00000300);
+        spring = ((vers.value() & 0x000000FF) >= 0x04);
         if ( spring )
             --year;
     }
 };
 
 
-class PlatformInfo_macOS : public PlatformInfo
-{
-public:
-    consteval PlatformInfo_macOS() : PlatformInfo(PLATFORM_MACOS, "macOS", false, false, 2009, "macOSX") { }
-
-    Version32 versionForYear(uint16_t year, bool spring) const override {
-        if ( (year > 2020) || ((year ==2020) && !spring) )
-            return majorVersionFromBaseYear(year, spring);       // 2020 - 2009 -> 11.0
-        else
-            return tenVersionFromBaseYear(year, spring, 2004);   // 2019 - 2004 -> 10.15
-    }
+class VIS_HIDDEN PlatformInfo_macOS : public PlatformInfo
+{
+public:
+    consteval PlatformInfo_macOS() : PlatformInfo(PLATFORM_MACOS, "macOS", false, false, true, 2009, &PlatformInfo_macOS::singleton, "macOSX") { }
 
     void yearForVersion(Version32 vers, uint16_t& year, bool& spring) const override {
         if ( vers >= Version32(11,0) )
@@ -206,27 +207,39 @@
             yearForTenMinorVersion(vers, 2004, year, spring);    // 10.15 -> 2019
     }
 
+    uint16_t minorVersionForSpring(uint16_t major) const override {
+        // The past releases have been 11.3, 12.3, 13.3, so assume that pattern for those releases.
+        if ( major <= 13 )
+            return 3;
+
+        // 14.4 needs a 4
+        // also assume that later releases are .4, just to be conservative
+        return 4;
+    }
+
     static const PlatformInfo_macOS singleton;
 protected:
-    consteval PlatformInfo_macOS(uint32_t v, CString nm, bool isSim) : PlatformInfo(v, nm, isSim, false, 2009) { }
+    consteval PlatformInfo_macOS(uint32_t v, CString nm, bool isSim, const PlatformInfo* info = &PlatformInfo_macOS::singleton) 
+                                    : PlatformInfo(v, nm, isSim, false, true, 2009, info) { }
 };
 const PlatformInfo_macOS        PlatformInfo_macOS::singleton;
 
 
-class PlatformInfo_iOS : public PlatformInfo
-{
-public:
-    consteval PlatformInfo_iOS() : PlatformInfo(PLATFORM_IOS, "iOS", false, true, 2006) { }
+class VIS_HIDDEN PlatformInfo_iOS : public PlatformInfo
+{
+public:
+    consteval PlatformInfo_iOS() : PlatformInfo(PLATFORM_IOS, "iOS", false, true, true, 2006, &PlatformInfo_iOS::singleton) { }
 
     static const PlatformInfo_iOS singleton;
 protected:
-    consteval PlatformInfo_iOS(uint32_t v, CString nm, bool isSim, CString altName = {}) : PlatformInfo(v, nm, isSim, !isSim, 2006, altName) { }
+    consteval PlatformInfo_iOS(uint32_t v, CString nm, bool isSim, const PlatformInfo* info = &PlatformInfo_iOS::singleton, CString altName = {})
+                                : PlatformInfo(v, nm, isSim, !isSim, true, 2006, info, altName) { }
 };
 const PlatformInfo_iOS      PlatformInfo_iOS::singleton;
 
 
 // iOS_simulator uses same versioning as iOS
-class PlatformInfo_iOS_simulator : public PlatformInfo_iOS
+class VIS_HIDDEN PlatformInfo_iOS_simulator : public PlatformInfo_iOS
 {
 public:
     consteval PlatformInfo_iOS_simulator() : PlatformInfo_iOS(PLATFORM_IOSSIMULATOR, "iOS-simulator", true) { }
@@ -237,23 +250,24 @@
 
 
 // tvOS uses same versioning as iOS
-class PlatformInfo_tvOS : public PlatformInfo_iOS
-{
-public:
-    consteval PlatformInfo_tvOS() : PlatformInfo_iOS(PLATFORM_TVOS, "tvOS", false) { }
+class VIS_HIDDEN PlatformInfo_tvOS : public PlatformInfo_iOS
+{
+public:
+    consteval PlatformInfo_tvOS() : PlatformInfo_iOS(PLATFORM_TVOS, "tvOS", false, &PlatformInfo_tvOS::singleton) { }
 
     static const PlatformInfo_tvOS  singleton;
 protected:
-    consteval PlatformInfo_tvOS(uint32_t v, CString nm, bool isSim) : PlatformInfo_iOS(v, nm, isSim) { }
+    consteval PlatformInfo_tvOS(uint32_t v, CString nm, bool isSim, const PlatformInfo* info = &PlatformInfo_tvOS::singleton)
+                                : PlatformInfo_iOS(v, nm, isSim, info) { }
 };
 const PlatformInfo_tvOS      PlatformInfo_tvOS::singleton;
 
 
-// tvOS_simulator uses same versioning as iOS
-class PlatformInfo_tvOS_simulator : public PlatformInfo_iOS
-{
-public:
-    consteval PlatformInfo_tvOS_simulator() : PlatformInfo_iOS(PLATFORM_TVOSSIMULATOR, "tvOS-simulator", false) { }
+// tvOS_simulator uses same versioning as tvOS
+class VIS_HIDDEN PlatformInfo_tvOS_simulator : public PlatformInfo_tvOS
+{
+public:
+    consteval PlatformInfo_tvOS_simulator() : PlatformInfo_tvOS(PLATFORM_TVOSSIMULATOR, "tvOS-simulator", true) { }
 
     static const PlatformInfo_tvOS_simulator    singleton;
 };
@@ -263,16 +277,18 @@
 
 
 // catalyst uses same versioning as iOS
-class PlatformInfo_macCatalyst : public PlatformInfo_iOS
-{
-public:
-    consteval PlatformInfo_macCatalyst() : PlatformInfo_iOS(PLATFORM_MACCATALYST, "macCatalyst", false, "Mac Catalyst") { }
+class VIS_HIDDEN PlatformInfo_macCatalyst : public PlatformInfo_iOS
+{
+public:
+    consteval PlatformInfo_macCatalyst() : PlatformInfo_iOS(PLATFORM_MACCATALYST, "macCatalyst", false, &PlatformInfo_iOS::singleton, "Mac Catalyst") {
+        supportsFairPlayEncryption = false;
+    }
 
     static const PlatformInfo_macCatalyst   singleton;
 };
 const PlatformInfo_macCatalyst PlatformInfo_macCatalyst::singleton;
 
-class PlatformInfo_zippered : public PlatformInfo_macOS
+class VIS_HIDDEN PlatformInfo_zippered : public PlatformInfo_macOS
 {
 public:
     consteval PlatformInfo_zippered() : PlatformInfo_macOS(PLATFORM_ZIPPERED, "zippered(macOS/Catalyst)", false) { }
@@ -282,20 +298,21 @@
 const PlatformInfo_zippered PlatformInfo_zippered::singleton;
 
 
-class PlatformInfo_watchOS : public PlatformInfo
-{
-public:
-    consteval PlatformInfo_watchOS() : PlatformInfo(PLATFORM_WATCHOS, "watchOS", false, true, 2013) { }
+class VIS_HIDDEN PlatformInfo_watchOS : public PlatformInfo
+{
+public:
+    consteval PlatformInfo_watchOS() : PlatformInfo(PLATFORM_WATCHOS, "watchOS", false, true, true, 2013, &PlatformInfo_watchOS::singleton) { }
 
     static const PlatformInfo_watchOS   singleton;
 protected:
-    consteval PlatformInfo_watchOS(uint32_t v, CString nm, bool isSim) : PlatformInfo(v, nm, isSim, !isSim, 2013) { }
+    consteval PlatformInfo_watchOS(uint32_t v, CString nm, bool isSim, const PlatformInfo* info = &PlatformInfo_watchOS::singleton)
+                                    : PlatformInfo(v, nm, isSim, !isSim, true, 2013, info) { }
 };
 const PlatformInfo_watchOS    PlatformInfo_watchOS::singleton;
 
 
 // watchOS_simulator uses same versioning as watchOS
-class PlatformInfo_watchOS_simulator: public PlatformInfo_watchOS
+class VIS_HIDDEN PlatformInfo_watchOS_simulator: public PlatformInfo_watchOS
 {
 public:
     consteval PlatformInfo_watchOS_simulator() : PlatformInfo_watchOS(PLATFORM_WATCHOSSIMULATOR, "watchOS-simulator", true) { }
@@ -305,21 +322,33 @@
 const PlatformInfo_watchOS_simulator PlatformInfo_watchOS_simulator::singleton;
 
 
-class PlatformInfo_bridgeOS : public PlatformInfo
-{
-public:
-    consteval PlatformInfo_bridgeOS() : PlatformInfo(PLATFORM_BRIDGEOS, "bridgeOS", false, false, 2015) { }
+class VIS_HIDDEN PlatformInfo_bridgeOS : public PlatformInfo
+{
+public:
+    consteval PlatformInfo_bridgeOS() : PlatformInfo(PLATFORM_BRIDGEOS, "bridgeOS", false, false, false, 2015, &PlatformInfo_bridgeOS::singleton) { }
+
+    uint16_t minorVersionForSpring(uint16_t major) const override {
+        // The past 2 releases have been 7.3 and 8.3, so assume that pattern for those releases.
+        if ( major <= 8 )
+            return 3;
+
+        // use .4 for future just in case it changes.  We'd rather be conservative for future
+        // than accidentally opt in something we shouldn't
+        return 4;
+    }
 
     static const PlatformInfo_bridgeOS singleton;
+protected:
+    consteval PlatformInfo_bridgeOS(uint32_t v, CString nm) : PlatformInfo(v, nm, false, false, false, 2015, &PlatformInfo_bridgeOS::singleton) { }
 };
 const PlatformInfo_bridgeOS         PlatformInfo_bridgeOS::singleton;
 
 
 
-class PlatformInfo_driverKit : public PlatformInfo
-{
-public:
-    consteval PlatformInfo_driverKit() : PlatformInfo(PLATFORM_DRIVERKIT, "driverKit", false, true, 2000) { }
+class VIS_HIDDEN PlatformInfo_driverKit : public PlatformInfo
+{
+public:
+    consteval PlatformInfo_driverKit() : PlatformInfo(PLATFORM_DRIVERKIT, "driverKit", false, true, false, 2000, &PlatformInfo_driverKit::singleton) { }
 
     static const PlatformInfo_driverKit singleton;
 };
@@ -327,14 +356,11 @@
 
 
 // firmware does not using versioning or epochs
-class PlatformInfo_firmware : public PlatformInfo
-{
-public:
-    consteval PlatformInfo_firmware() : PlatformInfo(PLATFORM_FIRMWARE, "firmware", false, false, 0, "free standing") { }
-
-    Version32 versionForYear(uint16_t year, bool spring) const override {
-        return Version32(1,0);
-    }
+class VIS_HIDDEN PlatformInfo_firmware : public PlatformInfo
+{
+public:
+    consteval PlatformInfo_firmware() : PlatformInfo(PLATFORM_FIRMWARE, "firmware", false, false, false, 0, &PlatformInfo_firmware::singleton, "free standing") { }
+
     void yearForVersion(Version32 vers, uint16_t& year, bool& spring) const override {
         year = 2020;
         spring = false;
@@ -346,14 +372,11 @@
 
 
 // sepOS does not using versioning or epochs
-class PlatformInfo_sepOS : public PlatformInfo
-{
-public:
-    consteval PlatformInfo_sepOS() : PlatformInfo(PLATFORM_SEPOS, "sepOS", false, false, 0) { }
-
-    Version32 versionForYear(uint16_t year, bool spring) const override {
-        return Version32(1,0);
-    }
+class VIS_HIDDEN PlatformInfo_sepOS : public PlatformInfo
+{
+public:
+    consteval PlatformInfo_sepOS() : PlatformInfo(PLATFORM_SEPOS, "sepOS", false, false, false, 0, &PlatformInfo_sepOS::singleton) { }
+
     void yearForVersion(Version32 vers, uint16_t& year, bool& spring) const override {
         year = 2020;
         spring = false;
@@ -362,6 +385,175 @@
 };
 const PlatformInfo_sepOS         PlatformInfo_sepOS::singleton;
 
+
+// macOS_exclaveCore OS versioning follows macOS versioning
+class VIS_HIDDEN PlatformInfo_macOS_exclaveCore : public PlatformInfo_macOS
+{
+public:
+    consteval PlatformInfo_macOS_exclaveCore() : PlatformInfo_macOS(PLATFORM_MACOS_EXCLAVECORE, "macOS-exclaveCore", false, &PlatformInfo_macOS_exclaveCore::singleton)
+    {
+        isExclaveCore = true;
+    }
+
+    static const PlatformInfo_macOS_exclaveCore     singleton;
+};
+const PlatformInfo_macOS_exclaveCore PlatformInfo_macOS_exclaveCore::singleton;
+
+// macOS_exclaveKit OS versioning follows macOS versioning
+class VIS_HIDDEN PlatformInfo_macOS_exclaveKit : public PlatformInfo_macOS
+{
+public:
+    consteval PlatformInfo_macOS_exclaveKit() : PlatformInfo_macOS(PLATFORM_MACOS_EXCLAVEKIT, "macOS-exclaveKit", false, &PlatformInfo_macOS_exclaveKit::singleton)
+    {
+        isExclaveKit = true;
+    }
+
+    static const PlatformInfo_macOS_exclaveKit     singleton;
+};
+const PlatformInfo_macOS_exclaveKit PlatformInfo_macOS_exclaveKit::singleton;
+
+
+// iOS_exclaveCore OS versioning follows iOS versioning
+class VIS_HIDDEN PlatformInfo_iOS_exclaveCore : public PlatformInfo_iOS
+{
+public:
+    consteval PlatformInfo_iOS_exclaveCore() : PlatformInfo_iOS(PLATFORM_IOS_EXCLAVECORE, "iOS-exclaveCore", false, &PlatformInfo_iOS_exclaveCore::singleton)
+    {
+        supportsFairPlayEncryption = false;
+        isExclaveCore = true;
+    }
+
+    static const PlatformInfo_iOS_exclaveCore     singleton;
+};
+const PlatformInfo_iOS_exclaveCore PlatformInfo_iOS_exclaveCore::singleton;
+
+// iOS_exclaveKit OS versioning follows iOS versioning
+class VIS_HIDDEN PlatformInfo_iOS_exclaveKit : public PlatformInfo_iOS
+{
+public:
+    consteval PlatformInfo_iOS_exclaveKit() : PlatformInfo_iOS(PLATFORM_IOS_EXCLAVEKIT, "iOS-exclaveKit", false, &PlatformInfo_iOS_exclaveKit::singleton)
+    {
+        supportsFairPlayEncryption = false;
+        isExclaveKit = true;
+    }
+
+    static const PlatformInfo_iOS_exclaveKit     singleton;
+};
+const PlatformInfo_iOS_exclaveKit PlatformInfo_iOS_exclaveKit::singleton;
+
+
+// tvOS_exclaveCore OS versioning follows tvOS versioning
+class VIS_HIDDEN PlatformInfo_tvOS_exclaveCore : public PlatformInfo_tvOS
+{
+public:
+    consteval PlatformInfo_tvOS_exclaveCore() : PlatformInfo_tvOS(PLATFORM_TVOS_EXCLAVECORE, "tvOS-exclaveCore", false, &PlatformInfo_tvOS_exclaveCore::singleton)
+    {
+        supportsFairPlayEncryption = false;
+        isExclaveCore = true;
+    }
+
+    static const PlatformInfo_tvOS_exclaveCore     singleton;
+};
+const PlatformInfo_tvOS_exclaveCore PlatformInfo_tvOS_exclaveCore::singleton;
+
+// tvOS_exclaveKit OS versioning follows tvOS versioning
+class VIS_HIDDEN PlatformInfo_tvOS_exclaveKit : public PlatformInfo_tvOS
+{
+public:
+    consteval PlatformInfo_tvOS_exclaveKit() : PlatformInfo_tvOS(PLATFORM_TVOS_EXCLAVEKIT, "tvOS-exclaveKit", false, &PlatformInfo_tvOS_exclaveKit::singleton)
+    {
+        supportsFairPlayEncryption = false;
+        isExclaveKit = true;
+    }
+
+    static const PlatformInfo_tvOS_exclaveKit     singleton;
+};
+const PlatformInfo_tvOS_exclaveKit PlatformInfo_tvOS_exclaveKit::singleton;
+
+
+// watchOS_exclaveCore OS versioning follows watchOS versioning
+class VIS_HIDDEN PlatformInfo_watchOS_exclaveCore : public PlatformInfo_watchOS
+{
+public:
+    consteval PlatformInfo_watchOS_exclaveCore() : PlatformInfo_watchOS(PLATFORM_WATCHOS_EXCLAVECORE, "watchOS-exclaveCore", false, &PlatformInfo_watchOS_exclaveCore::singleton)
+    {
+        supportsFairPlayEncryption = false;
+        isExclaveCore = true;
+    }
+
+    static const PlatformInfo_watchOS_exclaveCore  singleton;
+};
+const PlatformInfo_watchOS_exclaveCore PlatformInfo_watchOS_exclaveCore::singleton;
+
+// watchOS_exclaveKit OS versioning follows watchOS versioning
+class VIS_HIDDEN PlatformInfo_watchOS_exclaveKit : public PlatformInfo_watchOS
+{
+public:
+    consteval PlatformInfo_watchOS_exclaveKit() : PlatformInfo_watchOS(PLATFORM_WATCHOS_EXCLAVEKIT, "watchOS-exclaveKit", false, &PlatformInfo_watchOS_exclaveKit::singleton)
+    {
+        supportsFairPlayEncryption = false;
+        isExclaveKit = true;
+    }
+
+    static const PlatformInfo_watchOS_exclaveKit  singleton;
+};
+const PlatformInfo_watchOS_exclaveKit PlatformInfo_watchOS_exclaveKit::singleton;
+
+class VIS_HIDDEN PlatformInfo_visionOS : public PlatformInfo
+{
+public:
+    consteval PlatformInfo_visionOS() : PlatformInfo(PLATFORM_VISIONOS, "visionOS", false, true, true, 2022, &PlatformInfo_visionOS::singleton, "xrOS") {}
+
+    uint16_t minorVersionForSpring(uint16_t major) const override {
+        // The first spring release is 1.1
+        if ( major == 1 )
+            return 1;
+
+        // use .4 for future just in case it changes from the above.  We'd rather be conservative
+        // for future than accidentally opt in something we shouldn't
+        return 4;
+    }
+
+    static const PlatformInfo_visionOS singleton;
+protected:
+    consteval PlatformInfo_visionOS(uint32_t v, CString nm, bool isSim, const PlatformInfo* info = &PlatformInfo_visionOS::singleton, CString altName = {}) : PlatformInfo(v, nm, isSim, !isSim, true, 2022, info, altName) { }
+};
+const PlatformInfo_visionOS          PlatformInfo_visionOS::singleton;
+
+class VIS_HIDDEN PlatformInfo_visionOS_simulator : public PlatformInfo_visionOS
+{
+public:
+    consteval PlatformInfo_visionOS_simulator() : PlatformInfo_visionOS(PLATFORM_VISIONOSSIMULATOR, "visionOS-simulator", true, &PlatformInfo_visionOS::singleton, "xrOS-simulator") { }
+
+    static const PlatformInfo_visionOS_simulator    singleton;
+};
+const PlatformInfo_visionOS_simulator          PlatformInfo_visionOS_simulator::singleton;
+
+class VIS_HIDDEN PlatformInfo_visionOS_exclaveCore : public PlatformInfo_visionOS
+{
+public:
+    consteval PlatformInfo_visionOS_exclaveCore() : PlatformInfo_visionOS(PLATFORM_VISIONOS_EXCLAVECORE, "visionOS-exclaveCore", false, &PlatformInfo_visionOS_exclaveCore::singleton, "xrOS-exclaveCore")
+    {
+        supportsFairPlayEncryption = false;
+        isExclaveCore = true;
+    }
+
+    static const PlatformInfo_visionOS_exclaveCore  singleton;
+};
+const PlatformInfo_visionOS_exclaveCore          PlatformInfo_visionOS_exclaveCore::singleton;
+
+class VIS_HIDDEN PlatformInfo_visionOS_exclaveKit : public PlatformInfo_visionOS
+{
+public:
+    consteval PlatformInfo_visionOS_exclaveKit() : PlatformInfo_visionOS(PLATFORM_VISIONOS_EXCLAVEKIT, "visionOS-exclaveKit", false, &PlatformInfo_visionOS_exclaveKit::singleton, "xrOS-exclaveKit")
+    {
+        supportsFairPlayEncryption = false;
+        isExclaveKit = true;
+    }
+
+    static const PlatformInfo_visionOS_exclaveKit  singleton;
+};
+const PlatformInfo_visionOS_exclaveKit          PlatformInfo_visionOS_exclaveKit::singleton;
 
 
 
@@ -381,6 +573,19 @@
     &PlatformInfo_driverKit::singleton,
     &PlatformInfo_firmware::singleton,
     &PlatformInfo_sepOS::singleton,
+    &PlatformInfo_visionOS::singleton,
+    &PlatformInfo_visionOS_simulator::singleton,
+    &PlatformInfo_macOS_exclaveCore::singleton,
+    &PlatformInfo_macOS_exclaveKit::singleton,
+    &PlatformInfo_iOS_exclaveCore::singleton,
+    &PlatformInfo_iOS_exclaveKit::singleton,
+    &PlatformInfo_tvOS_exclaveCore::singleton,
+    &PlatformInfo_tvOS_exclaveKit::singleton,
+    &PlatformInfo_watchOS_exclaveCore::singleton,
+    &PlatformInfo_watchOS_exclaveKit::singleton,
+    &PlatformInfo_visionOS_exclaveCore::singleton,
+    &PlatformInfo_visionOS_exclaveKit::singleton,
+
 };
 
 
@@ -390,9 +595,8 @@
 //
 
 
-Platform::Platform(uint32_t platformNumber)
-{
-    _info = nullptr;
+Platform::Platform(uint32_t platformNumber) : _info(nullptr), _value(0)
+{
     for (const PlatformInfo* p : PlatformInfo::knownPlatformInfos) {
         assert(p->value != 0 && "PlatformInfo value uninitialized, this might be a problem with C++ static initializers order");
         if ( p->value == platformNumber ) {
@@ -400,6 +604,7 @@
             return;
         }
     }
+    _value = platformNumber;
 }
 
 Platform Platform::byName(std::string_view name) {
@@ -420,8 +625,9 @@
 
     // check if this is a raw platform number
     uint32_t num = 0;
-    if ( std::from_chars_result res = std::from_chars(name.begin(), name.end(), num);
-            res.ec == std::errc() && res.ptr == name.end()
+    const char* end = name.data() + name.size();
+    if ( std::from_chars_result res = std::from_chars(name.data(), end, num);
+            res.ec == std::errc() && res.ptr == end
             && Platform(num).valid().noError() )
         return Platform(num);
 
@@ -441,14 +647,27 @@
 
 bool Platform::empty() const
 {
-    return (_info == nullptr);
+    return (_info == nullptr) && _value == 0;
 }
 
 CString Platform::name() const
 {
-    if ( _info == nullptr )
+    if ( _info == nullptr ) {
+        if ( _value != 0 )
+            return "future";
         return "unknown";
+    }
     return _info->name;
+}
+
+Platform Platform::basePlatform() const
+{
+    if ( _info == nullptr ) {
+        if ( _value != 0 )
+            return *this;
+        return Platform();
+    }
+    return Platform(*(_info->basePlatformInfo));
 }
 
 bool Platform::isSimulator() const
@@ -456,6 +675,20 @@
     if ( _info == nullptr )
         return false;
     return _info->isSimulator;
+}
+
+bool Platform::isExclaveCore() const
+{
+    if ( _info == nullptr )
+        return false;
+    return _info->isExclaveCore;
+}
+
+bool Platform::isExclaveKit() const
+{
+    if ( _info == nullptr )
+        return false;
+    return _info->isExclaveKit;
 }
 
 
@@ -481,17 +714,25 @@
     return false;
 }
 
+CString Platform::libSystemDir() const
+{
+    if ( *this == Platform::sepOS )
+        return "";
+    if ( *this == Platform::firmware )
+        return "";
+    if ( isExclaveCore() )
+        return "";
+
+    if ( *this == Platform::driverKit )
+        return "/System/DriverKit/usr/lib/system/";
+    if ( isExclaveKit() )
+        return "/System/ExclaveKit/usr/lib/system/";
+    return "/usr/lib/system/";
+}
+
 uint32_t Platform::value() const
 {
-    return _info ? _info->value : 0;
-}
-
-Version32 Platform::version(Platform::Epoch e) const
-{
-    if ( _info != nullptr )
-        return _info->versionForEpoch(e);
-    else
-        return Version32(0,0);
+    return _info ? _info->value : _value;
 }
 
 Platform::Epoch Platform::epoch(Version32 v) const
@@ -510,7 +751,9 @@
     return watchOS_simulator;
   #elif TARGET_OS_TV
     return tvOS_simulator;
-  #else
+  #elif TARGET_OS_VISION
+    return visionOS_simulator;  // before TARGET_OS_IOS because TARGET_OS_IOS is set on visionOS internal SDK
+  #elif TARGET_OS_IOS
     return iOS_simulator;
   #endif
 #elif TARGET_OS_EXCLAVEKIT
@@ -520,8 +763,8 @@
     return tvOS_exclaveKit;
   #elif TARGET_OS_IOS
     return iOS_exclaveKit;
-  #elif TARGET_FEATURE_XROS
-    return xrOS_exclaveKit;
+  #elif TARGET_OS_VISION
+    return visionOS_exclaveKit;
   #else
     return macOS_exclaveKit;
   #endif
@@ -531,6 +774,8 @@
     return watchOS;
 #elif TARGET_OS_TV
     return tvOS;
+#elif TARGET_OS_VISION
+    return visionOS;  // before TARGET_OS_IOS because TARGET_OS_IOS is set on visionOS internal SDK
 #elif TARGET_OS_IOS
     return iOS;
 #elif TARGET_OS_OSX
@@ -555,6 +800,19 @@
 constinit const Platform Platform::driverKit(         PlatformInfo_driverKit::singleton);
 constinit const Platform Platform::firmware(          PlatformInfo_firmware::singleton);
 constinit const Platform Platform::sepOS(             PlatformInfo_sepOS::singleton);
+constinit const Platform Platform::visionOS(          PlatformInfo_visionOS::singleton);
+constinit const Platform Platform::visionOS_simulator(PlatformInfo_visionOS_simulator::singleton);
+constinit const Platform Platform::macOS_exclaveCore(     PlatformInfo_macOS_exclaveCore::singleton);
+constinit const Platform Platform::macOS_exclaveKit(      PlatformInfo_macOS_exclaveKit::singleton);
+constinit const Platform Platform::iOS_exclaveCore(       PlatformInfo_iOS_exclaveCore::singleton);
+constinit const Platform Platform::iOS_exclaveKit(        PlatformInfo_iOS_exclaveKit::singleton);
+constinit const Platform Platform::tvOS_exclaveCore(      PlatformInfo_tvOS_exclaveCore::singleton);
+constinit const Platform Platform::tvOS_exclaveKit(       PlatformInfo_tvOS_exclaveKit::singleton);
+constinit const Platform Platform::watchOS_exclaveCore(   PlatformInfo_watchOS_exclaveCore::singleton);
+constinit const Platform Platform::watchOS_exclaveKit(    PlatformInfo_watchOS_exclaveKit::singleton);
+constinit const Platform Platform::visionOS_exclaveCore(  PlatformInfo_visionOS_exclaveCore::singleton);
+constinit const Platform Platform::visionOS_exclaveKit(   PlatformInfo_visionOS_exclaveKit::singleton);
+
 
 Error PlatformAndVersions::zip(const PlatformAndVersions& other)
 {
@@ -641,6 +899,20 @@
     if ( (vendor == nullptr) || (osVers == nullptr) )
         return Error("missing dashes in target triple '%s'", triple.c_str());
 
+
+    // also return architecture from triple
+    outArch = Architecture::byName(arch);
+    if ( outArch == Architecture() )
+        return Error("unknown architecture in target triple '%s'", triple.c_str());
+
+    // firmware uses triples like "thumbv7m-apple-unknown-macho"
+    if ( strcmp(osVers, "unknown") == 0 ) {
+        this->platform = Platform::firmware;
+        this->minOS    = Version32(0,0);
+        this->sdk      = Version32(0,0);
+        return Error::none();
+    }
+
     // split osVersion into osName and minOS version
     const size_t osVersLen = strlen(osVers);
     char osName[triple.size()+1];
@@ -654,17 +926,10 @@
             break;
         }
     }
-    if ( strlen(minOSVers) == 0 )
-        return Error("missing OS version in target triple '%s'", triple.c_str());
 
     //  macosx is historical name
     if ( strcmp(osName, "macosx") == 0 )
         strlcpy(osName, "macos", sizeof(osName));
-
-    // also return architecture from triple
-    outArch = Architecture::byName(arch);
-    if ( outArch == Architecture() )
-        return Error("unknown architecture in target triple '%s'", triple.c_str());
 
     // Apple sub-platforms are fourth part of triple, but need to be added to OS name to make platform name
     // e.g. "arm64-apple-tvos16.0-simulator" --> "tvos-simulator"
@@ -673,8 +938,16 @@
         strlcat(osName, env, sizeof(osName));
     }
     this->platform = Platform::byName(osName);
+
+    // EFIShell
+    if ( this->platform.empty() && CString(osName) == "windows-macho" )
+        this->platform = Platform::firmware;
+
     if ( this->platform.empty() )
         return Error("unknown OS in target triple '%s'", triple.c_str());
+
+    if ( (strlen(minOSVers) == 0) && (this->platform != Platform::firmware) )
+        return Error("missing OS version in target triple '%s'", triple.c_str());
 
     // get minOS from version trailing OS name in triple
     if (Error err = Version32::fromString(minOSVers, this->minOS))