retdec
break_fat.h
Go to the documentation of this file.
1 
7 #ifndef RETDEC_MACHO_EXTRACTOR_BREAK_FAT_H
8 #define RETDEC_MACHO_EXTRACTOR_BREAK_FAT_H
9 
10 #include <llvm/Object/MachO.h>
11 #include <llvm/Object/MachOUniversal.h>
12 #include <llvm/Support/ErrorOr.h>
13 
14 namespace retdec {
15 namespace macho_extractor {
16 
18 {
19  private:
20  bool valid = false;
21  bool isStatic = false;
22 
23  std::string path;
24  std::unique_ptr<llvm::object::MachOUniversalBinary> file;
25  llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> buffer;
26 
29  bool isArchive();
30  const char* getFileBufferStart();
31  bool getByArchFamily(
32  std::uint32_t cpuType,
33  llvm::object::MachOUniversalBinary::object_iterator &res);
34  bool extract(
35  llvm::object::MachOUniversalBinary::object_iterator &object,
36  const std::string &outPath);
38  std::uintptr_t archOffset ,
39  std::size_t archSize,
40  std::vector<std::string> &result);
42 
43  public:
44  BreakMachOUniversal(const std::string &path);
45 
48  bool isValid();
49  bool isStaticLibrary();
50  bool listArchitectures(
51  std::ostream &output,
52  bool withObjects = false);
54  std::ostream &output,
55  bool withObjects = false);
57 
60  bool extractAllArchives();
61  bool extractBestArchive(
62  const std::string &outPath);
64  unsigned index,
65  const std::string &outPath);
67  const std::string &familyName,
68  const std::string &outPath);
70  const std::string &machoArchName,
71  const std::string &outPath);
73 };
74 
75 } // namespace macho_extractor
76 } // namespace retdec
77 
78 #endif
bool extractArchiveForFamily(const std::string &familyName, const std::string &outPath)
Definition: break_fat.cpp:515
bool extractAllArchives()
Extracting methods.
Definition: break_fat.cpp:430
bool extract(llvm::object::MachOUniversalBinary::object_iterator &object, const std::string &outPath)
Definition: break_fat.cpp:185
llvm::ErrorOr< std::unique_ptr< llvm::MemoryBuffer > > buffer
Definition: break_fat.h:25
std::string path
Definition: break_fat.h:23
bool listArchitecturesJson(std::ostream &output, bool withObjects=false)
Definition: break_fat.cpp:353
BreakMachOUniversal(const std::string &path)
Definition: break_fat.cpp:97
bool extractArchiveWithIndex(unsigned index, const std::string &outPath)
Definition: break_fat.cpp:488
bool isArchive()
Auxiliary methods.
Definition: break_fat.cpp:128
std::unique_ptr< llvm::object::MachOUniversalBinary > file
Definition: break_fat.h:24
bool getByArchFamily(std::uint32_t cpuType, llvm::object::MachOUniversalBinary::object_iterator &res)
Definition: break_fat.cpp:163
bool extractArchiveForArchitecture(const std::string &machoArchName, const std::string &outPath)
Definition: break_fat.cpp:592
bool extractBestArchive(const std::string &outPath)
Definition: break_fat.cpp:462
bool valid
Definition: break_fat.h:20
const char * getFileBufferStart()
Definition: break_fat.cpp:152
bool isStaticLibrary()
Definition: break_fat.cpp:281
bool getObjectNamesForArchive(std::uintptr_t archOffset, std::size_t archSize, std::vector< std::string > &result)
Definition: break_fat.cpp:212
bool isStatic
Definition: break_fat.h:21
bool listArchitectures(std::ostream &output, bool withObjects=false)
Definition: break_fat.cpp:292
bool isValid()
Information methods.
Definition: break_fat.cpp:272
Definition: archive_wrapper.h:19