retdec
elf_notes.h
Go to the documentation of this file.
1 
7 #ifndef RETDEC_FILEFORMAT_TYPES_NOTE_SECTION_ELF_NOTE_H
8 #define RETDEC_FILEFORMAT_TYPES_NOTE_SECTION_ELF_NOTE_H
9 
10 #include <string>
11 #include <vector>
12 
14 
15 namespace retdec {
16 namespace fileformat {
17 
22 {
23  public:
24  std::string name;
25  std::size_t type;
26 
27  // Type must be combined with name to tell how to interpret data
28 
29  std::size_t dataOffset;
30  std::size_t dataLength;
31 
34  bool isEmptyNote() const;
36 };
37 
42 {
43  private:
44  const SecSeg* secSeg;
45  std::vector<ElfNoteEntry> notes;
46 
47  bool malformed = false;
48  std::string error;
49 
50  public:
53  ElfNoteSecSeg(const SecSeg* assocSecSeg);
55 
58  void setMalformed(const std::string& message = "corrupted note");
60 
63  void addNote(ElfNoteEntry&& note);
64  void addNote(const ElfNoteEntry& note);
66 
69  std::vector<ElfNoteEntry> getNotes() const;
70  std::string getErrorMessage() const;
71  std::size_t getSecSegOffset() const;
72  std::size_t getSecSegLength() const;
73  std::string getSectionName() const;
75 
78  bool isNamedSection() const;
79  bool isMalformed() const;
80  bool isEmpty() const;
82 };
83 
84 } // namespace fileformat
85 } // namespace retdec
86 
87 #endif
Definition: elf_notes.h:22
std::size_t dataOffset
file offset of note data
Definition: elf_notes.h:29
std::string name
interpreted name (owner)
Definition: elf_notes.h:24
std::size_t type
owner specific type
Definition: elf_notes.h:25
std::size_t dataLength
length of note data
Definition: elf_notes.h:30
bool isEmptyNote() const
Definition: elf_notes.cpp:16
Definition: elf_notes.h:42
void addNote(ElfNoteEntry &&note)
Definition: elf_notes.cpp:43
std::string getSectionName() const
Definition: elf_notes.cpp:97
std::size_t getSecSegLength() const
Definition: elf_notes.cpp:88
std::size_t getSecSegOffset() const
Definition: elf_notes.cpp:79
const SecSeg * secSeg
associated section or segment
Definition: elf_notes.h:44
bool isEmpty() const
Definition: elf_notes.cpp:124
void setMalformed(const std::string &message="corrupted note")
Definition: elf_notes.cpp:33
std::string getErrorMessage() const
Definition: elf_notes.cpp:70
std::vector< ElfNoteEntry > getNotes() const
Definition: elf_notes.cpp:61
bool isMalformed() const
Definition: elf_notes.cpp:115
bool isNamedSection() const
Definition: elf_notes.cpp:106
std::string error
possible error message
Definition: elf_notes.h:48
ElfNoteSecSeg(const SecSeg *assocSecSeg)
Definition: elf_notes.cpp:25
std::vector< ElfNoteEntry > notes
notes in segment or section
Definition: elf_notes.h:45
bool malformed
set to true if notes are malformed
Definition: elf_notes.h:47
Definition: sec_seg.h:24
Definition: archive_wrapper.h:19
Basic class for section and segment.