]> git.saurik.com Git - apple/dyld.git/blobdiff - dyld3/Closure.h
dyld-851.27.tar.gz
[apple/dyld.git] / dyld3 / Closure.h
index 20d5c0be4472b2a62372e9a7b92bc507757a7a64..628208bdb60c53ca537fed592429cdd47e2201a7 100644 (file)
@@ -110,7 +110,6 @@ struct VIS_HIDDEN TypedBytes
         topImage                = 36,  // sizeof(ImageNum)
         libDyldEntry            = 37,  // sizeof(ResolvedSymbolTarget)
         libSystemNum            = 38,  // sizeof(ImageNum)
         topImage                = 36,  // sizeof(ImageNum)
         libDyldEntry            = 37,  // sizeof(ResolvedSymbolTarget)
         libSystemNum            = 38,  // sizeof(ImageNum)
-        bootUUID                = 39,  // c-string 40
         mainEntry               = 40,  // sizeof(ResolvedSymbolTarget)
         startEntry              = 41,  // sizeof(ResolvedSymbolTarget)     // used by programs built with crt1.o
         cacheOverrides          = 42,  // sizeof(PatchEntry) * count       // used if process uses interposing or roots (cached dylib overrides)
         mainEntry               = 40,  // sizeof(ResolvedSymbolTarget)
         startEntry              = 41,  // sizeof(ResolvedSymbolTarget)     // used by programs built with crt1.o
         cacheOverrides          = 42,  // sizeof(PatchEntry) * count       // used if process uses interposing or roots (cached dylib overrides)
@@ -119,8 +118,9 @@ struct VIS_HIDDEN TypedBytes
         selectorTable           = 45,  // uint32_t + (sizeof(ObjCSelectorImage) * count) + hashTable size
         classTable              = 46,  // (3 * uint32_t) + (sizeof(ObjCClassImage) * count) + classHashTable size + protocolHashTable size
         warning                 = 47,  // len = uint32_t + length path + 1, use one entry per warning
         selectorTable           = 45,  // uint32_t + (sizeof(ObjCSelectorImage) * count) + hashTable size
         classTable              = 46,  // (3 * uint32_t) + (sizeof(ObjCClassImage) * count) + classHashTable size + protocolHashTable size
         warning                 = 47,  // len = uint32_t + length path + 1, use one entry per warning
-        duplicateClassesTable   = 48, // duplicateClassesHashTable
-   };
+        duplicateClassesTable   = 48,  // duplicateClassesHashTable
+        progVars                = 49,  // sizeof(uint32_t)
+    };
 
     Type         type          : 8;
     uint32_t     payloadLength : 24;
 
     Type         type          : 8;
     uint32_t     payloadLength : 24;
@@ -165,6 +165,8 @@ struct VIS_HIDDEN Image : ContainerTypedBytes
     bool                hasObjC() const;
     bool                hasInitializers() const;
     bool                hasPrecomputedObjC() const;
     bool                hasObjC() const;
     bool                hasInitializers() const;
     bool                hasPrecomputedObjC() const;
+    bool                fixupsNotEncoded() const;   // minimal closure, dyld must parse and apply fixups
+    bool                rebasesNotEncoded() const;
     bool                hasTerminators() const;
     bool                hasReadOnlyData() const;
     bool                hasChainedFixups() const;
     bool                hasTerminators() const;
     bool                hasReadOnlyData() const;
     bool                hasChainedFixups() const;
@@ -176,7 +178,6 @@ struct VIS_HIDDEN Image : ContainerTypedBytes
     bool                is64() const;
     bool                neverUnload() const;
     bool                cwdMustBeThisDir() const;
     bool                is64() const;
     bool                neverUnload() const;
     bool                cwdMustBeThisDir() const;
-    bool                isPlatformBinary() const;
     bool                overridableDylib() const;
     bool                hasFileModTimeAndInode(uint64_t& inode, uint64_t& mTime) const;
     void                forEachCDHash(void (^handler)(const uint8_t cdHash[20], bool& stop)) const;
     bool                overridableDylib() const;
     bool                hasFileModTimeAndInode(uint64_t& inode, uint64_t& mTime) const;
     void                forEachCDHash(void (^handler)(const uint8_t cdHash[20], bool& stop)) const;
@@ -192,6 +193,7 @@ struct VIS_HIDDEN Image : ContainerTypedBytes
     bool                hasPathWithHash(const char* path, uint32_t hash) const;
     bool                isOverrideOfDyldCacheImage(ImageNum& cacheImageNum) const;
     uint64_t            textSize() const;
     bool                hasPathWithHash(const char* path, uint32_t hash) const;
     bool                isOverrideOfDyldCacheImage(ImageNum& cacheImageNum) const;
     uint64_t            textSize() const;
+    const char*         variantString() const; // "minimal" or "full" closure
 
        union ResolvedSymbolTarget
     {
 
        union ResolvedSymbolTarget
     {
@@ -202,13 +204,13 @@ struct VIS_HIDDEN Image : ContainerTypedBytes
                         unused          : 62;       // all zeros
         };
         struct SharedCache {
                         unused          : 62;       // all zeros
         };
         struct SharedCache {
-            uint64_t    kind            :  2,       // kindSharedCache
-                        offset          : 62;
+            uint64_t    kind            :  2;       // kindSharedCache
+            int64_t     offset          : 62;
         };
         struct Image {
             uint64_t    kind            :  2,       // kindImage
         };
         struct Image {
             uint64_t    kind            :  2,       // kindImage
-                        imageNum        : 22,       // ImageNum
-                        offset          : 40;
+                        imageNum        : 22;       // ImageNum
+            int64_t     offset          : 40;
         };
         struct Absolute {
             uint64_t    kind            :  2,       // kindAbsolute
         };
         struct Absolute {
             uint64_t    kind            :  2,       // kindAbsolute
@@ -227,6 +229,7 @@ struct VIS_HIDDEN Image : ContainerTypedBytes
             return (raw != rhs.raw);
         }
      };
             return (raw != rhs.raw);
         }
      };
+     static_assert(sizeof(ResolvedSymbolTarget) == 8, "Invalid size");
 
 
     // ObjC optimisations
 
 
     // ObjC optimisations
@@ -358,6 +361,8 @@ struct VIS_HIDDEN Image : ContainerTypedBytes
     void                forEachTextReloc(void (^rebase)(uint32_t imageOffsetToRebase, bool& stop),
                                          void (^bind)(uint32_t imageOffsetToBind, ResolvedSymbolTarget bindTarget, bool& stop)) const;
 
     void                forEachTextReloc(void (^rebase)(uint32_t imageOffsetToRebase, bool& stop),
                                          void (^bind)(uint32_t imageOffsetToBind, ResolvedSymbolTarget bindTarget, bool& stop)) const;
 
+    bool                forEachBind(void (^bind)(uint64_t imageOffsetToBind, ResolvedSymbolTarget bindTarget, bool& stop)) const;
+
        static_assert(sizeof(ResolvedSymbolTarget) == 8, "Overflow in size of SymbolTargetLocation");
 
     static uint32_t     hashFunction(const char*);
        static_assert(sizeof(ResolvedSymbolTarget) == 8, "Overflow in size of SymbolTargetLocation");
 
     static uint32_t     hashFunction(const char*);
@@ -368,7 +373,9 @@ private:
     friend class ClosureBuilder;
     friend class ClosureWriter;
     friend class LaunchClosureWriter;
     friend class ClosureBuilder;
     friend class ClosureWriter;
     friend class LaunchClosureWriter;
-
+    friend class RebasePatternBuilder;
+    friend class BindPatternBuilder;
+    
     uint32_t             pageSize() const;
 
     struct Flags
     uint32_t             pageSize() const;
 
     struct Flags
@@ -394,7 +401,10 @@ private:
                         hasReadOnlyData              : 1,
                         hasChainedFixups             : 1,
                         hasPrecomputedObjC           : 1,
                         hasReadOnlyData              : 1,
                         hasChainedFixups             : 1,
                         hasPrecomputedObjC           : 1,
-                        padding                      : 17;
+                        fixupsNotEncoded             : 1,
+                        rebasesNotEncoded            : 1,
+                        hasOverrideImageNum          : 1,
+                        padding                      : 14;
     };
 
     static_assert(sizeof(Flags) == sizeof(uint64_t), "Flags overflow");
     };
 
     static_assert(sizeof(Flags) == sizeof(uint64_t), "Flags overflow");
@@ -655,7 +665,8 @@ struct VIS_HIDDEN Closure : public ContainerTypedBytes
 {
     size_t              size() const;
     const ImageArray*   images() const;
 {
     size_t              size() const;
     const ImageArray*   images() const;
-    ImageNum            topImage() const;
+    ImageNum            topImageNum() const;
+    const Image*        topImage() const;
     void                deallocate() const;
 
     friend class ClosureWriter;
     void                deallocate() const;
 
     friend class ClosureWriter;
@@ -696,7 +707,6 @@ struct VIS_HIDDEN LaunchClosure : public Closure
     };
 
     bool                builtAgainstDyldCache(uuid_t cacheUUID) const;
     };
 
     bool                builtAgainstDyldCache(uuid_t cacheUUID) const;
-    const char*         bootUUID() const;
     void                forEachMustBeMissingFile(void (^handler)(const char* path, bool& stop)) const;
     void                forEachSkipIfExistsFile(void (^handler)(const SkippedFile& file, bool& stop)) const;
     void                forEachEnvVar(void (^handler)(const char* keyEqualValue, bool& stop)) const;
     void                forEachMustBeMissingFile(void (^handler)(const char* path, bool& stop)) const;
     void                forEachSkipIfExistsFile(void (^handler)(const SkippedFile& file, bool& stop)) const;
     void                forEachEnvVar(void (^handler)(const char* keyEqualValue, bool& stop)) const;
@@ -708,6 +718,7 @@ struct VIS_HIDDEN LaunchClosure : public Closure
     void                forEachInterposingTuple(void (^handler)(const InterposingTuple& tuple, bool& stop)) const;
     bool                usedAtPaths() const;
     bool                usedFallbackPaths() const;
     void                forEachInterposingTuple(void (^handler)(const InterposingTuple& tuple, bool& stop)) const;
     bool                usedAtPaths() const;
     bool                usedFallbackPaths() const;
+    bool                usedInterposing() const;
     bool                selectorHashTable(Array<Image::ObjCSelectorImage>& imageNums,
                                           const ObjCSelectorOpt*& hashTable) const;
     bool                classAndProtocolHashTables(Array<Image::ObjCClassImage>& imageNums,
     bool                selectorHashTable(Array<Image::ObjCSelectorImage>& imageNums,
                                           const ObjCSelectorOpt*& hashTable) const;
     bool                classAndProtocolHashTables(Array<Image::ObjCClassImage>& imageNums,
@@ -716,9 +727,10 @@ struct VIS_HIDDEN LaunchClosure : public Closure
     void                duplicateClassesHashTable(const ObjCClassDuplicatesOpt*& duplicateClassesHashTable) const;
     bool                hasInsertedLibraries() const;
     bool                hasInterposings() const;
     void                duplicateClassesHashTable(const ObjCClassDuplicatesOpt*& duplicateClassesHashTable) const;
     bool                hasInsertedLibraries() const;
     bool                hasInterposings() const;
+    bool                hasProgramVars(uint32_t& runtimeOffset) const;
     
     
-    static bool         buildClosureCachePath(const char* mainExecutablePath, char closurePath[], const char* tempDir,
-                                              bool makeDirsIfMissing);
+    static bool         buildClosureCachePath(const char* mainExecutablePath, const char* envp[],
+                                              bool makeDirsIfMissing, char closurePath[]);
 
 private:
     friend class LaunchClosureWriter;
 
 private:
     friend class LaunchClosureWriter;
@@ -729,7 +741,9 @@ private:
                         usedFallbackPaths        :  1,
                         initImageCount           : 16,
                         hasInsertedLibraries     :  1,
                         usedFallbackPaths        :  1,
                         initImageCount           : 16,
                         hasInsertedLibraries     :  1,
-                        padding                  : 13;
+                        hasProgVars              :  1,
+                        usedInterposing          :  1,
+                        padding                  : 11;
     };
     const Flags&        getFlags() const;
 };
     };
     const Flags&        getFlags() const;
 };