LIEF: Library to Instrument Executable Formats Version 0.17.0
Loading...
Searching...
No Matches
LIEF::COFF::Section Class Reference

This class represents a COFF section. More...

#include <Section.hpp>

Inheritance diagram for LIEF::COFF::Section:
Collaboration diagram for LIEF::COFF::Section:

Classes

struct  ComdatInfo
 This structure wraps comdat information which is composed of the symbol associated with the comdat section and its selection flag. More...
 

Public Types

using COMDAT_SELECTION = AuxiliarySectionDefinition::COMDAT_SELECTION
 
using CHARACTERISTICS = LIEF::PE::Section::CHARACTERISTICS
 Mirror Characteristics from PE.
 
using relocations_t = std::vector<Relocation*>
 Container for the relocations in this section (owned by the Binary object)
 
using it_relocations = ref_iterator<relocations_t&, Relocation*>
 Iterator that outputs Relocation&.
 
using it_const_relocations = const_ref_iterator<const relocations_t&, const Relocation*>
 Iterator that outputs const Relocation&.
 
using symbols_t = std::vector<Symbol*>
 Container for the symbols associated with this section (owned by the Binary object)
 
using it_symbols = ref_iterator<symbols_t&, Symbol*>
 Iterator that outputs Symbol&.
 
using it_const_symbols = const_ref_iterator<const symbols_t&, const Symbol*>
 Iterator that outputs const Symbol&.
 
- Public Types inherited from LIEF::Object
template<class T >
using output_t = add_pointer_t<decay_t<T>>
 
template<class T >
using output_const_t = add_pointer_t<add_const_t<decay_t<T>>>
 

Public Member Functions

uint32_t sizeof_raw_data () const
 Return the size of the data in the section.
 
uint32_t virtual_size () const
 Virtual size of the section (should be 0)
 
span< const uint8_t > content () const override
 Content wrapped by this section.
 
uint32_t pointerto_raw_data () const
 Offset to the section's content.
 
uint32_t pointerto_relocation () const
 Offset to the relocation table.
 
uint32_t pointerto_line_numbers () const
 The file pointer to the beginning of line-number entries for the section.
 
uint16_t numberof_relocations () const
 Number of relocations.
 
uint16_t numberof_line_numbers () const
 Number of line number entries (if any).
 
uint32_t characteristics () const
 Characteristics of the section: it provides information about the permissions of the section when mapped. It can also provide information about the purpose of the section (contain code, BSS-like, ...)
 
bool has_characteristic (CHARACTERISTICS c) const
 Check if the section has the given CHARACTERISTICS.
 
std::vector< CHARACTERISTICScharacteristics_list () const
 List of the section characteristics.
 
bool is_discardable () const
 True if the section can be discarded as needed.
 
void clear (uint8_t c)
 
it_relocations relocations ()
 Iterator over the relocations associated with this section.
 
it_const_relocations relocations () const
 
it_symbols symbols ()
 Iterator over the symbols associated with this section.
 
it_const_symbols symbols () const
 
optional< ComdatInfocomdat_info () const
 Return comdat infomration (only if the section has the CHARACTERISTICS::LNK_COMDAT characteristic)
 
bool has_extended_relocations () const
 Whether there is a large number of relocations whose number need to be stored in the virtual address attribute.
 
void content (const std::vector< uint8_t > &data) override
 Change section content.
 
void name (std::string name) override
 Change the section's name.
 
void virtual_size (uint32_t virtual_sz)
 
void pointerto_raw_data (uint32_t ptr)
 
void pointerto_relocation (uint32_t ptr)
 
void pointerto_line_numbers (uint32_t ptr)
 
void numberof_relocations (uint16_t nb)
 
void numberof_line_numbers (uint16_t nb)
 
void sizeof_raw_data (uint32_t size)
 
void characteristics (uint32_t characteristics)
 
std::string to_string () const
 
 ~Section () override=default
 
virtual std::string name () const
 section's name
 
- Public Member Functions inherited from LIEF::Section
 Section ()=default
 
 Section (std::string name)
 
 ~Section () override=default
 
Sectionoperator= (const Section &)=default
 
 Section (const Section &)=default
 
virtual const std::string & fullname () const
 Return the complete section's name which might trailing (0) bytes.
 
virtual void size (uint64_t size)
 Change the section size.
 
virtual uint64_t size () const
 section's size (size in the binary, not the virtual size)
 
virtual uint64_t offset () const
 Offset in the binary.
 
virtual uint64_t virtual_address () const
 Address where the section should be mapped.
 
virtual void virtual_address (uint64_t virtual_address)
 
virtual void offset (uint64_t offset)
 
double entropy () const
 Section's entropy.
 
size_t search (uint64_t integer, size_t pos, size_t size) const
 
size_t search (const std::vector< uint8_t > &pattern, size_t pos=0) const
 
size_t search (const std::string &pattern, size_t pos=0) const
 
size_t search (uint64_t integer, size_t pos=0) const
 
std::vector< size_t > search_all (uint64_t v, size_t size) const
 
std::vector< size_t > search_all (uint64_t v) const
 
std::vector< size_t > search_all (const std::string &v) const
 
void accept (Visitor &visitor) const override
 Method so that the visitor can visit us.
 
- Public Member Functions inherited from LIEF::Object
 Object ()
 
 Object (const Object &other)
 
Objectoperator= (const Object &other)
 
template<class T >
output_t< T > as ()
 
template<class T >
output_const_t< T > as () const
 
virtual bool operator== (const Object &other) const
 
virtual bool operator!= (const Object &other) const
 
virtual ~Object ()
 

Static Public Member Functions

static std::unique_ptr< Sectionparse (BinaryStream &stream)
 Parse a section from the given stream.
 

Additional Inherited Members

- Static Public Attributes inherited from LIEF::Section
static constexpr size_t npos = -1
 

Detailed Description

This class represents a COFF section.

Member Typedef Documentation

◆ CHARACTERISTICS

◆ COMDAT_SELECTION

◆ it_const_relocations

◆ it_const_symbols

Iterator that outputs const Symbol&.

◆ it_relocations

◆ it_symbols

◆ relocations_t

Container for the relocations in this section (owned by the Binary object)

◆ symbols_t

using LIEF::COFF::Section::symbols_t = std::vector<Symbol*>

Container for the symbols associated with this section (owned by the Binary object)

Constructor & Destructor Documentation

◆ ~Section()

LIEF::COFF::Section::~Section ( )
overridedefault

Member Function Documentation

◆ characteristics() [1/2]

uint32_t LIEF::COFF::Section::characteristics ( ) const
inline

Characteristics of the section: it provides information about the permissions of the section when mapped. It can also provide information about the purpose of the section (contain code, BSS-like, ...)

◆ characteristics() [2/2]

void LIEF::COFF::Section::characteristics ( uint32_t characteristics)
inline

◆ characteristics_list()

std::vector< CHARACTERISTICS > LIEF::COFF::Section::characteristics_list ( ) const
inline

List of the section characteristics.

References LIEF::PE::Section::characteristics_to_list().

◆ clear()

void LIEF::COFF::Section::clear ( uint8_t c)
inline

◆ comdat_info()

optional< ComdatInfo > LIEF::COFF::Section::comdat_info ( ) const

Return comdat infomration (only if the section has the CHARACTERISTICS::LNK_COMDAT characteristic)

◆ content() [1/2]

span< const uint8_t > LIEF::COFF::Section::content ( ) const
inlineoverridevirtual

Content wrapped by this section.

Reimplemented from LIEF::Section.

◆ content() [2/2]

void LIEF::COFF::Section::content ( const std::vector< uint8_t > & )
inlineoverridevirtual

Change section content.

Reimplemented from LIEF::Section.

◆ has_characteristic()

bool LIEF::COFF::Section::has_characteristic ( CHARACTERISTICS c) const
inline

Check if the section has the given CHARACTERISTICS.

◆ has_extended_relocations()

bool LIEF::COFF::Section::has_extended_relocations ( ) const
inline

Whether there is a large number of relocations whose number need to be stored in the virtual address attribute.

◆ is_discardable()

bool LIEF::COFF::Section::is_discardable ( ) const
inline

True if the section can be discarded as needed.

This is typically the case for debug-related sections

◆ name() [1/2]

virtual std::string LIEF::Section::name ( ) const
inlinevirtual

section's name

Reimplemented from LIEF::Section.

◆ name() [2/2]

void LIEF::COFF::Section::name ( std::string name)
overridevirtual

Change the section's name.

Reimplemented from LIEF::Section.

◆ numberof_line_numbers() [1/2]

uint16_t LIEF::COFF::Section::numberof_line_numbers ( ) const
inline

Number of line number entries (if any).

◆ numberof_line_numbers() [2/2]

void LIEF::COFF::Section::numberof_line_numbers ( uint16_t nb)
inline

◆ numberof_relocations() [1/2]

uint16_t LIEF::COFF::Section::numberof_relocations ( ) const
inline

Number of relocations.

Warning
If the number of relocations is greater than 0xFFFF (maximum value for 16-bits integer), then the number of relocations is stored in the virtual address of the first relocation.

◆ numberof_relocations() [2/2]

void LIEF::COFF::Section::numberof_relocations ( uint16_t nb)
inline

◆ parse()

static std::unique_ptr< Section > LIEF::COFF::Section::parse ( BinaryStream & stream)
static

Parse a section from the given stream.

◆ pointerto_line_numbers() [1/2]

uint32_t LIEF::COFF::Section::pointerto_line_numbers ( ) const
inline

The file pointer to the beginning of line-number entries for the section.

This is set to zero if there are no COFF line numbers. This value should be zero for an image because COFF debugging information is deprecated and modern debug information relies on the PDB files.

◆ pointerto_line_numbers() [2/2]

void LIEF::COFF::Section::pointerto_line_numbers ( uint32_t ptr)
inline

◆ pointerto_raw_data() [1/2]

uint32_t LIEF::COFF::Section::pointerto_raw_data ( ) const
inline

Offset to the section's content.

◆ pointerto_raw_data() [2/2]

void LIEF::COFF::Section::pointerto_raw_data ( uint32_t ptr)
inline

◆ pointerto_relocation() [1/2]

uint32_t LIEF::COFF::Section::pointerto_relocation ( ) const
inline

Offset to the relocation table.

◆ pointerto_relocation() [2/2]

void LIEF::COFF::Section::pointerto_relocation ( uint32_t ptr)
inline

◆ relocations() [1/2]

it_relocations LIEF::COFF::Section::relocations ( )
inline

Iterator over the relocations associated with this section.

◆ relocations() [2/2]

it_const_relocations LIEF::COFF::Section::relocations ( ) const
inline

◆ sizeof_raw_data() [1/2]

uint32_t LIEF::COFF::Section::sizeof_raw_data ( ) const
inline

Return the size of the data in the section.

◆ sizeof_raw_data() [2/2]

void LIEF::COFF::Section::sizeof_raw_data ( uint32_t size)
inline

◆ symbols() [1/2]

it_symbols LIEF::COFF::Section::symbols ( )
inline

Iterator over the symbols associated with this section.

◆ symbols() [2/2]

it_const_symbols LIEF::COFF::Section::symbols ( ) const
inline

◆ to_string()

std::string LIEF::COFF::Section::to_string ( ) const

Referenced by operator<<.

◆ virtual_size() [1/2]

uint32_t LIEF::COFF::Section::virtual_size ( ) const
inline

Virtual size of the section (should be 0)

◆ virtual_size() [2/2]

void LIEF::COFF::Section::virtual_size ( uint32_t virtual_sz)
inline

The documentation for this class was generated from the following file: