]> git.saurik.com Git - apple/dyld.git/blobdiff - launch-cache/MachOFileAbstraction.hpp
dyld-551.3.tar.gz
[apple/dyld.git] / launch-cache / MachOFileAbstraction.hpp
index 7a65370a64b6e92c7e5731a2fc174f3312db650b..ebd298d46a876d870923ab5e6f4c0d0659b76094 100644 (file)
@@ -96,8 +96,29 @@ struct uuid_command {
 
 #ifndef CPU_SUBTYPE_X86_64_H
        #define CPU_SUBTYPE_X86_64_H            ((cpu_subtype_t) 8) 
-#endif 
+#endif
+
+
+#define DYLD_CACHE_ADJ_V2_FORMAT                               0x7F
+
+#define DYLD_CACHE_ADJ_V2_POINTER_32                   0x01
+#define DYLD_CACHE_ADJ_V2_POINTER_64                   0x02
+#define DYLD_CACHE_ADJ_V2_DELTA_32                         0x03
+#define DYLD_CACHE_ADJ_V2_DELTA_64                         0x04
+#define DYLD_CACHE_ADJ_V2_ARM64_ADRP                   0x05
+#define DYLD_CACHE_ADJ_V2_ARM64_OFF12                  0x06
+#define DYLD_CACHE_ADJ_V2_ARM64_BR26                   0x07
+#define DYLD_CACHE_ADJ_V2_ARM_MOVW_MOVT                        0x08
+#define DYLD_CACHE_ADJ_V2_ARM_BR24                             0x09
+#define DYLD_CACHE_ADJ_V2_THUMB_MOVW_MOVT              0x0A
+#define DYLD_CACHE_ADJ_V2_THUMB_BR22                   0x0B
+#define DYLD_CACHE_ADJ_V2_IMAGE_OFF_32                 0x0C
 
+#define MH_HAS_OBJC                    0x40000000
+
+#ifndef CPU_SUBTYPE_ARM64_E
+       #define CPU_SUBTYPE_ARM64_E    2
+#endif
 
 #include "FileAbstraction.hpp"
 #include "Architectures.hpp"
@@ -115,6 +136,10 @@ struct ArchPair
                        return (this->arch < other.arch);
                return (this->subtype < other.subtype);
        }
+
+       bool operator==(const ArchPair& other) const { 
+        return this->arch == other.arch  &&  this->subtype == other.subtype;
+       }
 };
 
 
@@ -801,7 +826,7 @@ public:
                 const macho_segment_command<P>* segcmd = (macho_segment_command<P>*)cmd;
                 if (0 == strncmp(segname, segcmd->segname(), 16)) {
                     return segcmd;
-                }
+              }
             }
             cmd = (macho_load_command<P>*)(((uint8_t*)cmd)+cmd->cmdsize());
         }
@@ -821,6 +846,8 @@ public:
             }
         }
 
+               if (strcmp(segname, "__DATA") == 0)
+                       return getSection("__DATA_CONST", sectname);
         return NULL;
     }
 
@@ -915,7 +942,7 @@ inline uint64_t read_uleb128(const uint8_t*& p, const uint8_t* end) {
 }
        
 
-static int64_t read_sleb128(const uint8_t*& p, const uint8_t* end)
+inline int64_t read_sleb128(const uint8_t*& p, const uint8_t* end)
 {
        int64_t result = 0;
        int bit = 0;
@@ -924,7 +951,7 @@ static int64_t read_sleb128(const uint8_t*& p, const uint8_t* end)
                if (p == end)
                        throw "malformed sleb128";
                byte = *p++;
-               result |= ((byte & 0x7f) << bit);
+               result |= (((int64_t)(byte & 0x7f)) << bit);
                bit += 7;
        } while (byte & 0x80);
        // sign extend negative numbers