16#ifndef LIEF_COFF_SECTION_H
17#define LIEF_COFF_SECTION_H
101 return pointer_to_relocations_;
110 return pointer_to_linenumbers_;
119 return number_of_relocations_;
124 return number_of_linenumbers_;
131 return characteristics_;
152 std::fill(content_.begin(), content_.end(), c);
180 static constexpr auto MAX_RELOC = 65535;
185 void content(
const std::vector<uint8_t>& data)
override {
192 virtual_size_ = virtual_sz;
200 pointer_to_relocations_ = ptr;
204 pointer_to_linenumbers_ = ptr;
208 number_of_relocations_ = nb;
212 number_of_linenumbers_ = nb;
247 std::vector<uint8_t> content_;
248 uint32_t virtual_size_ = 0;
249 uint32_t pointer_to_relocations_ = 0;
250 uint32_t pointer_to_linenumbers_ = 0;
251 uint16_t number_of_relocations_ = 0;
252 uint16_t number_of_linenumbers_ = 0;
253 uint32_t characteristics_ = 0;
258 String* coff_string_ =
nullptr;
Class that is used to a read stream of data from different sources.
Definition BinaryStream.hpp:33
COMDAT_SELECTION
Values for the AuxiliarySectionDefinition::selection attribute.
Definition AuxiliarySectionDefinition.hpp:68
Definition COFF/Parser.hpp:35
This class represents a COFF relocation.
Definition COFF/Relocation.hpp:34
friend std::ostream & operator<<(std::ostream &os, const Section &sec)
Definition COFF/Section.hpp:237
const_ref_iterator< const symbols_t &, const Symbol * > it_const_symbols
Iterator that outputs const Symbol&.
Definition COFF/Section.hpp:74
void pointerto_relocation(uint32_t ptr)
Definition COFF/Section.hpp:199
uint32_t characteristics() const
Characteristics of the section: it provides information about the permissions of the section when map...
Definition COFF/Section.hpp:130
std::vector< Symbol * > symbols_t
Container for the symbols associated with this section (owned by the Binary object).
Definition COFF/Section.hpp:68
uint16_t numberof_line_numbers() const
Number of line number entries (if any).
Definition COFF/Section.hpp:123
void name(std::string name) override
Change the section's name.
String * coff_string()
Return the COFF string associated with the section's name (or a nullptr).
Definition COFF/Section.hpp:227
std::string to_string() const
it_relocations relocations()
Iterator over the relocations associated with this section.
Definition COFF/Section.hpp:156
it_const_relocations relocations() const
Definition COFF/Section.hpp:160
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:179
void virtual_size(uint32_t virtual_sz)
Definition COFF/Section.hpp:191
const_ref_iterator< const relocations_t &, const Relocation * > it_const_relocations
Iterator that outputs const Relocation&.
Definition COFF/Section.hpp:63
void content(const std::vector< uint8_t > &data) override
Change section content.
Definition COFF/Section.hpp:185
ref_iterator< symbols_t &, Symbol * > it_symbols
Iterator that outputs Symbol&.
Definition COFF/Section.hpp:71
it_const_symbols symbols() const
Definition COFF/Section.hpp:169
uint32_t pointerto_relocation() const
Offset to the relocation table.
Definition COFF/Section.hpp:100
std::vector< Relocation * > relocations_t
Container for the relocations in this section (owned by the Binary object).
Definition COFF/Section.hpp:57
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:95
void sizeof_raw_data(uint32_t size)
Definition COFF/Section.hpp:215
const String * coff_string() const
Definition COFF/Section.hpp:231
void numberof_relocations(uint16_t nb)
Definition COFF/Section.hpp:207
span< const uint8_t > content() const override
Content wrapped by this section.
Definition COFF/Section.hpp:90
std::vector< CHARACTERISTICS > characteristics_list() const
List of the section characteristics.
Definition COFF/Section.hpp:140
void pointerto_raw_data(uint32_t ptr)
Definition COFF/Section.hpp:195
void numberof_line_numbers(uint16_t nb)
Definition COFF/Section.hpp:211
~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:109
void clear(uint8_t c)
Definition COFF/Section.hpp:151
AuxiliarySectionDefinition::COMDAT_SELECTION COMDAT_SELECTION
Definition COFF/Section.hpp:44
friend class Parser
Definition COFF/Section.hpp:41
bool has_characteristic(CHARACTERISTICS c) const
Check if the section has the given CHARACTERISTICS.
Definition COFF/Section.hpp:135
uint32_t virtual_size() const
Virtual size of the section (should be 0).
Definition COFF/Section.hpp:85
uint16_t numberof_relocations() const
Number of relocations.
Definition COFF/Section.hpp:118
ref_iterator< relocations_t &, Relocation * > it_relocations
Iterator that outputs Relocation&.
Definition COFF/Section.hpp:60
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:219
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:203
uint32_t sizeof_raw_data() const
Return the size of the data in the section.
Definition COFF/Section.hpp:80
bool is_discardable() const
True if the section can be discarded as needed.
Definition COFF/Section.hpp:147
it_symbols symbols()
Iterator over the symbols associated with this section.
Definition COFF/Section.hpp:165
This class represents a string located in the COFF string table.
Definition String.hpp:34
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
Class which represents an abstracted section.
Definition Abstract/Section.hpp:29
virtual void size(uint64_t size)
Change the section size.
Definition Abstract/Section.hpp:59
virtual std::string name() const
section's name
Definition Abstract/Section.hpp:43
virtual uint64_t offset() const
Offset in the binary.
Definition Abstract/Section.hpp:69
Definition optional.hpp:23
Iterator which returns reference on container's values.
Definition iterators.hpp:45
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:40
tcb::span< ElementType, Extent > span
Definition span.hpp:22
ref_iterator< CT, U, typename decay_t< CT >::const_iterator > const_ref_iterator
Iterator which return const ref on container's values.
Definition iterators.hpp:286
This structure wraps comdat information which is composed of the symbol associated with the comdat se...
Definition COFF/Section.hpp:48
COMDAT_SELECTION kind
Definition COFF/Section.hpp:50
Symbol * symbol
Definition COFF/Section.hpp:49
#define LIEF_API
Definition visibility.h:43