LIEF: Library to Instrument Executable Formats Version 0.17.0
|
Loading...
Searching...
No Matches
Go to the documentation of this file.
16#ifndef LIEF_COFF_SECTION_H
17#define LIEF_COFF_SECTION_H
44 using COMDAT_SELECTION = AuxiliarySectionDefinition::COMDAT_SELECTION;
49 Symbol* symbol =
nullptr;
50 COMDAT_SELECTION kind = COMDAT_SELECTION::NONE;
55 using relocations_t = std::vector<Relocation*>;
58 using it_relocations = ref_iterator<relocations_t&, Relocation*>;
61 using it_const_relocations = const_ref_iterator<const relocations_t&, const Relocation*>;
64 using symbols_t = std::vector<Symbol*>;
67 using it_symbols = ref_iterator<symbols_t&, Symbol*>;
70 using it_const_symbols = const_ref_iterator<const symbols_t&, const Symbol*>;
73 static std::unique_ptr<Section>
parse(BinaryStream& stream);
86 span<const uint8_t>
content()
const override {
99 return pointer_to_relocations_;
108 return pointer_to_linenumbers_;
117 return number_of_relocations_;
122 return number_of_linenumbers_;
129 return characteristics_;
134 return (characteristics() & (uint32_t)c) > 0;
146 return has_characteristic(CHARACTERISTICS::MEM_DISCARDABLE);
150 std::fill(content_.begin(), content_.end(), c);
178 return has_characteristic(CHARACTERISTICS::LNK_NRELOC_OVFL) &&
179 numberof_relocations() == std::numeric_limits<uint16_t>::max();
182 void content(
const std::vector<uint8_t>& data)
override {
186 void name(std::string name)
override;
189 virtual_size_ = virtual_sz;
197 pointer_to_relocations_ = ptr;
201 pointer_to_linenumbers_ = ptr;
205 number_of_relocations_ = nb;
209 number_of_linenumbers_ = nb;
217 characteristics_ = characteristics;
232 std::vector<uint8_t> content_;
233 uint32_t virtual_size_ = 0;
234 uint32_t pointer_to_relocations_ = 0;
235 uint32_t pointer_to_linenumbers_ = 0;
236 uint16_t number_of_relocations_ = 0;
237 uint16_t number_of_linenumbers_ = 0;
238 uint32_t characteristics_ = 0;
240 relocations_t relocations_;
Class that is used to a read stream of data from different sources.
Definition BinaryStream.hpp:33
Definition COFF/Parser.hpp:34
This class represents a COFF relocation.
Definition COFF/Relocation.hpp:34
This class represents a COFF section.
Definition COFF/Section.hpp:39
friend std::ostream & operator<<(std::ostream &os, const Section &sec)
Definition COFF/Section.hpp:222
void pointerto_relocation(uint32_t ptr)
Definition COFF/Section.hpp:196
uint32_t characteristics() const
Characteristics of the section: it provides information about the permissions of the section when map...
Definition COFF/Section.hpp:128
uint16_t numberof_line_numbers() const
Number of line number entries (if any).
Definition COFF/Section.hpp:121
void name(std::string name) override
Change the section's name.
std::string to_string() const
it_relocations relocations()
Iterator over the relocations associated with this section.
Definition COFF/Section.hpp:154
it_const_relocations relocations() const
Definition COFF/Section.hpp:158
bool has_extended_relocations() const
Whether there is a large number of relocations whose number need to be stored in the virtual address ...
Definition COFF/Section.hpp:177
void virtual_size(uint32_t virtual_sz)
Definition COFF/Section.hpp:188
void content(const std::vector< uint8_t > &data) override
Change section content.
Definition COFF/Section.hpp:182
it_const_symbols symbols() const
Definition COFF/Section.hpp:167
uint32_t pointerto_relocation() const
Offset to the relocation table.
Definition COFF/Section.hpp:98
static std::unique_ptr< Section > parse(BinaryStream &stream)
Parse a section from the given stream.
uint32_t pointerto_raw_data() const
Offset to the section's content.
Definition COFF/Section.hpp:93
void sizeof_raw_data(uint32_t size)
Definition COFF/Section.hpp:212
void numberof_relocations(uint16_t nb)
Definition COFF/Section.hpp:204
span< const uint8_t > content() const override
Content wrapped by this section.
Definition COFF/Section.hpp:88
std::vector< CHARACTERISTICS > characteristics_list() const
List of the section characteristics.
Definition COFF/Section.hpp:138
void pointerto_raw_data(uint32_t ptr)
Definition COFF/Section.hpp:192
void numberof_line_numbers(uint16_t nb)
Definition COFF/Section.hpp:208
~Section() override=default
uint32_t pointerto_line_numbers() const
The file pointer to the beginning of line-number entries for the section.
Definition COFF/Section.hpp:107
void clear(uint8_t c)
Definition COFF/Section.hpp:149
bool has_characteristic(CHARACTERISTICS c) const
Check if the section has the given CHARACTERISTICS.
Definition COFF/Section.hpp:133
uint32_t virtual_size() const
Virtual size of the section (should be 0)
Definition COFF/Section.hpp:83
uint16_t numberof_relocations() const
Number of relocations.
Definition COFF/Section.hpp:116
optional< ComdatInfo > comdat_info() const
Return comdat infomration (only if the section has the CHARACTERISTICS::LNK_COMDAT characteristic)
void characteristics(uint32_t characteristics)
Definition COFF/Section.hpp:216
LIEF::PE::Section::CHARACTERISTICS CHARACTERISTICS
Mirror Characteristics from PE.
Definition COFF/Section.hpp:54
void pointerto_line_numbers(uint32_t ptr)
Definition COFF/Section.hpp:200
uint32_t sizeof_raw_data() const
Return the size of the data in the section.
Definition COFF/Section.hpp:78
bool is_discardable() const
True if the section can be discarded as needed.
Definition COFF/Section.hpp:145
it_symbols symbols()
Iterator over the symbols associated with this section.
Definition COFF/Section.hpp:163
This class represents a COFF symbol.
Definition COFF/Symbol.hpp:35
static std::vector< CHARACTERISTICS > characteristics_to_list(uint32_t value)
CHARACTERISTICS
Definition PE/Section.hpp:56
virtual std::string name() const
section's name
Definition Abstract/Section.hpp:44
Definition AuxiliarySymbol.hpp:29
const char * to_string(AuxiliarySectionDefinition::COMDAT_SELECTION e)
const char * to_string(CODE_PAGES e)
LIEF namespace.
Definition Abstract/Binary.hpp:39
#define LIEF_API
Definition visibility.h:41