retdec
intel_hex_format.h
Go to the documentation of this file.
1 
7 #ifndef RETDEC_FILEFORMAT_FILE_FORMAT_INTEL_HEX_INTEL_HEX_FORMAT_H
8 #define RETDEC_FILEFORMAT_FILE_FORMAT_INTEL_HEX_INTEL_HEX_FORMAT_H
9 
10 #include "retdec/common/address.h"
13 
14 namespace retdec {
15 namespace fileformat {
16 
20 class IntelHexFormat : public FileFormat
21 {
22  private:
26  std::size_t bytesPerWord = 0;
28  std::vector<unsigned char> serialized;
29 
32  void initStructures();
33  void initializeSections();
35 
38  virtual std::size_t initSectionTableHashOffsets() override;
40  public:
41  IntelHexFormat(std::string pathToFile, LoadFlags loadFlags = LoadFlags::NONE);
42  IntelHexFormat(std::istream &inputStream, LoadFlags loadFlags = LoadFlags::NONE);
43  IntelHexFormat(const std::uint8_t *data, std::size_t size, LoadFlags loadFlags = LoadFlags::NONE);
44 
47  virtual retdec::utils::Endianness getEndianness() const override;
48  virtual std::size_t getBytesPerWord() const override;
49  virtual bool hasMixedEndianForDouble() const override;
51 
54  virtual std::size_t getDeclaredFileLength() const override;
55  virtual bool areSectionsValid() const override;
56  virtual bool isObjectFile() const override;
57  virtual bool isDll() const override;
58  virtual bool isExecutable() const override;
59  virtual bool getMachineCode(unsigned long long &result) const override;
60  virtual bool getAbiVersion(unsigned long long &result) const override;
61  virtual bool getImageBaseAddress(unsigned long long &imageBase) const override;
62  virtual bool getEpAddress(unsigned long long &result) const override;
63  virtual bool getEpOffset(unsigned long long &epOffset) const override;
64  virtual Architecture getTargetArchitecture() const override;
65  virtual std::size_t getDeclaredNumberOfSections() const override;
66  virtual std::size_t getDeclaredNumberOfSegments() const override;
67  virtual std::size_t getSectionTableOffset() const override;
68  virtual std::size_t getSectionTableEntrySize() const override;
69  virtual std::size_t getSegmentTableOffset() const override;
70  virtual std::size_t getSegmentTableEntrySize() const override;
72 
80  void setBytesPerWord(std::size_t b);
82 };
83 
84 } // namespace fileformat
85 } // namespace retdec
86 
87 #endif
Definition: address.h:21
Definition: file_format.h:45
LoadFlags loadFlags
load flags for configurable file loading
Definition: file_format.h:51
Definition: intel_hex_format.h:21
void initStructures()
Definition: intel_hex_format.cpp:52
virtual bool isDll() const override
Definition: intel_hex_format.cpp:157
virtual std::size_t getSegmentTableOffset() const override
Definition: intel_hex_format.cpp:233
std::vector< unsigned char > serialized
serialized binary data
Definition: intel_hex_format.h:28
void initializeSections()
Definition: intel_hex_format.cpp:67
virtual std::size_t initSectionTableHashOffsets() override
Definition: intel_hex_format.cpp:122
virtual retdec::utils::Endianness getEndianness() const override
Definition: intel_hex_format.cpp:127
virtual bool hasMixedEndianForDouble() const override
Definition: intel_hex_format.cpp:137
virtual std::size_t getDeclaredNumberOfSegments() const override
Definition: intel_hex_format.cpp:217
virtual std::size_t getSegmentTableEntrySize() const override
Definition: intel_hex_format.cpp:238
retdec::utils::Endianness endianness
Intel HEX provides no information about endianness.
Definition: intel_hex_format.h:25
virtual std::size_t getSectionTableEntrySize() const override
Definition: intel_hex_format.cpp:228
Architecture architecture
Intel HEX provides no information about architecture.
Definition: intel_hex_format.h:24
IntelHexParser parser
parser of input file
Definition: intel_hex_format.h:23
virtual bool getAbiVersion(unsigned long long &result) const override
Definition: intel_hex_format.cpp:173
virtual std::size_t getDeclaredNumberOfSections() const override
Definition: intel_hex_format.cpp:212
retdec::common::Address epOffset
offset of entry point
Definition: intel_hex_format.h:27
virtual Architecture getTargetArchitecture() const override
Definition: intel_hex_format.cpp:207
virtual bool getMachineCode(unsigned long long &result) const override
Definition: intel_hex_format.cpp:167
virtual std::size_t getDeclaredFileLength() const override
Definition: intel_hex_format.cpp:142
virtual std::size_t getSectionTableOffset() const override
Definition: intel_hex_format.cpp:223
virtual bool isExecutable() const override
Definition: intel_hex_format.cpp:162
virtual std::size_t getBytesPerWord() const override
Definition: intel_hex_format.cpp:132
void setTargetArchitecture(Architecture a)
Definition: intel_hex_format.cpp:247
virtual bool getEpOffset(unsigned long long &epOffset) const override
Definition: intel_hex_format.cpp:196
virtual bool areSectionsValid() const override
Definition: intel_hex_format.cpp:147
virtual bool isObjectFile() const override
Definition: intel_hex_format.cpp:152
virtual bool getImageBaseAddress(unsigned long long &imageBase) const override
Definition: intel_hex_format.cpp:179
IntelHexFormat(std::string pathToFile, LoadFlags loadFlags=LoadFlags::NONE)
Definition: intel_hex_format.cpp:22
void setBytesPerWord(std::size_t b)
Definition: intel_hex_format.cpp:265
std::size_t bytesPerWord
Intel HEX provides no information about word size.
Definition: intel_hex_format.h:26
void setEndianness(retdec::utils::Endianness e)
Definition: intel_hex_format.cpp:256
virtual bool getEpAddress(unsigned long long &result) const override
Definition: intel_hex_format.cpp:185
The IntelHexParser class - Intel HEX semantical analysis.
Definition: intel_hex_parser.h:40
Address, address pair and other derived class representation.
Definition of FileFormat class.
Definition of IntelHexSection and IntelHexParser classes.
LoadFlags
Definition: fftypes.h:69
@ NONE
Definition: fftypes.h:70
Architecture
Definition: fftypes.h:59
Endianness
Definition: byte_value_storage.h:21
Definition: archive_wrapper.h:19