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 <fstream>
18 #include <map>
19 #include <string>
20 
21 // we follow
22 // https://developer.apple.com/library/mac/#documentation/DeveloperTools/Conceptual/MachORuntime/Reference/reference.html
23 
25 {
26 public:
27  osx_fat_readert(std::ifstream &, message_handlert &);
28 
29  bool has_gb() const { return has_gb_arch; }
30 
31  bool extract_gb(
32  const std::string &source,
33  const std::string &dest) const;
34 
35 private:
38 };
39 
40 bool is_osx_fat_header(char hdr[8]);
41 
43 {
44 public:
45  osx_mach_o_readert(std::istream &, message_handlert &);
46 
47  struct sectiont
48  {
49  sectiont(const std::string &_name, std::size_t _offset, std::size_t _size)
50  : name(_name), offset(_offset), size(_size)
51  {
52  }
53 
54  std::string name;
55  std::size_t offset;
56  std::size_t size;
57  };
58 
59  using sectionst = std::map<std::string, sectiont>;
61 
62  bool has_section(const std::string &name) const
63  {
64  return sections.find(name) != sections.end();
65  }
66 
67 private:
69  std::istream &in;
70 
71  void process_commands(uint32_t ncmds, std::size_t offset, bool need_swap);
72 
73  void process_sections_32(uint32_t nsects, bool need_swap);
74  void process_sections_64(uint32_t nsects, bool need_swap);
75 };
76 
77 bool is_osx_mach_object(char hdr[8]);
78 
79 #endif // CPROVER_GOTO_PROGRAMS_OSX_FAT_READER_H
messaget
Class that provides messages with a built-in verbosity 'level'.
Definition: message.h:154
osx_mach_o_readert
Definition: osx_fat_reader.h:42
osx_mach_o_readert::sectionst
std::map< std::string, sectiont > sectionst
Definition: osx_fat_reader.h:59
osx_mach_o_readert::process_sections_32
void process_sections_32(uint32_t nsects, bool need_swap)
Definition: osx_fat_reader.cpp:150
osx_mach_o_readert::sectiont::size
std::size_t size
Definition: osx_fat_reader.h:56
osx_mach_o_readert::sectiont
Definition: osx_fat_reader.h:47
is_osx_mach_object
bool is_osx_mach_object(char hdr[8])
osx_fat_readert::log
messaget log
Definition: osx_fat_reader.h:36
osx_fat_readert::has_gb
bool has_gb() const
Definition: osx_fat_reader.h:29
osx_fat_readert
Definition: osx_fat_reader.h:24
osx_mach_o_readert::in
std::istream & in
Definition: osx_fat_reader.h:69
osx_mach_o_readert::log
messaget log
Definition: osx_fat_reader.h:68
is_osx_fat_header
bool is_osx_fat_header(char hdr[8])
Definition: osx_fat_reader.cpp:57
osx_mach_o_readert::sections
sectionst sections
Definition: osx_fat_reader.h:60
message_handlert
Definition: message.h:27
osx_mach_o_readert::sectiont::sectiont
sectiont(const std::string &_name, std::size_t _offset, std::size_t _size)
Definition: osx_fat_reader.h:49
osx_mach_o_readert::process_sections_64
void process_sections_64(uint32_t nsects, bool need_swap)
Definition: osx_fat_reader.cpp:174
osx_mach_o_readert::sectiont::offset
std::size_t offset
Definition: osx_fat_reader.h:55
osx_fat_readert::extract_gb
bool extract_gb(const std::string &source, const std::string &dest) const
Definition: osx_fat_reader.cpp:122
osx_mach_o_readert::has_section
bool has_section(const std::string &name) const
Definition: osx_fat_reader.h:62
osx_mach_o_readert::sectiont::name
std::string name
Definition: osx_fat_reader.h:54
osx_fat_readert::has_gb_arch
bool has_gb_arch
Definition: osx_fat_reader.h:37
osx_fat_readert::osx_fat_readert
osx_fat_readert(std::ifstream &, message_handlert &)
Definition: osx_fat_reader.cpp:74
message.h
osx_mach_o_readert::process_commands
void process_commands(uint32_t ncmds, std::size_t offset, bool need_swap)
Definition: osx_fat_reader.cpp:198
osx_mach_o_readert::osx_mach_o_readert
osx_mach_o_readert(std::istream &, message_handlert &)
Definition: osx_fat_reader.cpp:269