]> git.saurik.com Git - apple/dyld.git/blob - interlinked-dylibs/MachOProxy.h
dyld-421.2.tar.gz
[apple/dyld.git] / interlinked-dylibs / MachOProxy.h
1 //
2 // DylibProxy.h
3 // dyld
4 //
5 // Created by Louis Gerbarg on 1/27/16.
6 //
7 //
8
9 #ifndef MachOProxy_h
10 #define MachOProxy_h
11
12 #include <map>
13 #include <set>
14 #include <string>
15 #include <vector>
16 #include <cstdint>
17
18 #include <sys/stat.h>
19
20 struct MachOProxy {
21 MachOProxy(const std::string& p, ino_t i, time_t t, uint32_t o, uint32_t s, bool r) :
22 path(p), fatFileOffset(o), fileSize(s), lastModTime(t), inode(i), installNameOffsetInTEXT(0), rootlessProtected(r) {
23 bzero( &uuid, sizeof( uuid_t ) );
24 }
25
26 struct Segment {
27 std::string name;
28 uint64_t size;
29 uint64_t sizeOfSections;
30 uint32_t diskSize;
31 uint32_t fileOffset;
32 uint8_t p2align;
33 uint8_t protection;
34 };
35
36 const std::string path;
37 const uint32_t fatFileOffset;
38 const uint32_t fileSize;
39 const time_t lastModTime;
40 const ino_t inode;
41 const bool rootlessProtected;
42 std::string installName;
43 std::set<std::string> installNameAliases;
44 uint32_t installNameOffsetInTEXT;
45 std::set<std::string> dependencies;
46 std::set<std::string> dependents;
47 uuid_t uuid;
48 std::vector<Segment> segments;
49
50 const uint8_t* getBuffer();
51 const bool isDylib();
52 const bool isExecutable();
53 bool addAlias(const std::string& alias);
54
55 static std::map<std::string, MachOProxy*> findDylibInfo(const std::string& path, bool warnOnProblems=false, bool ignoreUncacheableDylibsInExecutables=false);
56
57 private:
58 bool _dylib;
59 bool _executable;
60
61 template <typename P>
62 std::string machoParser(bool ignoreUncacheableDylibsInExecutables);
63 };
64
65
66 #endif /* MachOProxy_h */