CBMC
osx_fat_reader.h
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module: Read OS X Fat Binaries
4 
5 Author:
6 
7 \*******************************************************************/
8 
11 
12 #ifndef CPROVER_GOTO_PROGRAMS_OSX_FAT_READER_H
13 #define CPROVER_GOTO_PROGRAMS_OSX_FAT_READER_H
14 
15 #include <util/message.h>
16 
17 #include <cstdint>
18 #include <fstream>
19 #include <map>
20 #include <string>
21 
22 // we follow
23 // https://developer.apple.com/library/mac/#documentation/DeveloperTools/Conceptual/MachORuntime/Reference/reference.html
24 
26 {
27 public:
28  osx_fat_readert(std::ifstream &, message_handlert &);
29 
30  bool has_gb() const { return has_gb_arch; }
31 
32  bool extract_gb(
33  const std::string &source,
34  const std::string &dest) const;
35 
36 private:
39 };
40 
41 bool is_osx_fat_header(char hdr[8]);
42 
44 {
45 public:
46  osx_mach_o_readert(std::istream &, message_handlert &);
47 
48  struct sectiont
49  {
50  sectiont(const std::string &_name, std::size_t _offset, std::size_t _size)
51  : name(_name), offset(_offset), size(_size)
52  {
53  }
54 
55  std::string name;
56  std::size_t offset;
57  std::size_t size;
58  };
59 
60  using sectionst = std::map<std::string, sectiont>;
62 
63  bool has_section(const std::string &name) const
64  {
65  return sections.find(name) != sections.end();
66  }
67 
68 private:
70  std::istream &in;
71 
72  void process_commands(uint32_t ncmds, std::size_t offset, bool need_swap);
73 
74  void process_sections_32(uint32_t nsects, bool need_swap);
75  void process_sections_64(uint32_t nsects, bool need_swap);
76 };
77 
78 bool is_osx_mach_object(char hdr[4]);
79 
80 #endif // CPROVER_GOTO_PROGRAMS_OSX_FAT_READER_H
Class that provides messages with a built-in verbosity 'level'.
Definition: message.h:155
osx_fat_readert(std::ifstream &, message_handlert &)
bool extract_gb(const std::string &source, const std::string &dest) const
bool has_gb() const
std::istream & in
void process_commands(uint32_t ncmds, std::size_t offset, bool need_swap)
std::map< std::string, sectiont > sectionst
osx_mach_o_readert(std::istream &, message_handlert &)
void process_sections_32(uint32_t nsects, bool need_swap)
bool has_section(const std::string &name) const
void process_sections_64(uint32_t nsects, bool need_swap)
bool is_osx_fat_header(char hdr[8])
bool is_osx_mach_object(char hdr[4])
sectiont(const std::string &_name, std::size_t _offset, std::size_t _size)