cprover
osx_fat_reader.h
Go to the documentation of this file.
1/*******************************************************************\
2
3Module: Read OS X Fat Binaries
4
5Author:
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{
26public:
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
35private:
38};
39
40bool is_osx_fat_header(char hdr[8]);
41
43{
44public:
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
67private:
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
77bool is_osx_mach_object(char hdr[8]);
78
79#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[8])
sectiont(const std::string &_name, std::size_t _offset, std::size_t _size)