LIEF: Library to Instrument Executable Formats Version
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
LIEF::ELF::Section Class Reference

Class wich represents an ELF Section. More...

#include <Section.hpp>

Inheritance diagram for LIEF::ELF::Section:
Inheritance graph
[legend]
Collaboration diagram for LIEF::ELF::Section:
Collaboration graph
[legend]

Public Types

using segments_t = std::vector< Segment * >
 
using it_segments = ref_iterator< segments_t & >
 
using it_const_segments = const_ref_iterator< const segments_t & >
 
- 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

 Section (const uint8_t *data, ELF_CLASS type)
 
 Section (const details::Elf64_Shdr &header)
 
 Section (const details::Elf32_Shdr &header)
 
 Section (const std::string &name, ELF_SECTION_TYPES type=ELF_SECTION_TYPES::SHT_PROGBITS)
 
Sectionoperator= (Section other)
 
 Section (const Section &other)
 
void swap (Section &other)
 
ELF_SECTION_TYPES type () const
 
span< const uint8_t > content () const override
 Section's content.
 
void content (const std::vector< uint8_t > &data) override
 Set section content.
 
void content (std::vector< uint8_t > &&data)
 
uint64_t flags () const
 Section flags LIEF::ELF::ELF_SECTION_FLAGS.
 
bool has (ELF_SECTION_FLAGS flag) const
 True if the section has the given flag
 
bool has (const Segment &segment) const
 True if the section is wrapped by the given Segment
 
std::set< ELF_SECTION_FLAGSflags_list () const
 Return section flags as a std::set
 
uint64_t size () const override
 section's size (size in the binary, not the virtual size)
 
void size (uint64_t size) override
 Change the section size.
 
void offset (uint64_t offset) override
 
uint64_t offset () const override
 Offset in the binary.
 
uint64_t file_offset () const
 
uint64_t original_size () const
 Original size of the section's data.
 
uint64_t alignment () const
 Section file alignment.
 
uint64_t information () const
 Section information. This meaning of this value depends on the section's type.
 
uint64_t entry_size () const
 This function returns the size of an element in the case of a section that contains an array.
 
uint32_t link () const
 Index to another section.
 
Sectionclear (uint8_t value=0)
 Clear the content of the section with the given value
 
void add (ELF_SECTION_FLAGS flag)
 Add the given ELF_SECTION_FLAGS.
 
void remove (ELF_SECTION_FLAGS flag)
 Remove the given ELF_SECTION_FLAGS.
 
void type (ELF_SECTION_TYPES type)
 
void flags (uint64_t flags)
 
void clear_flags ()
 
void file_offset (uint64_t offset)
 
void link (uint32_t link)
 
void information (uint32_t info)
 
void alignment (uint64_t alignment)
 
void entry_size (uint64_t entry_size)
 
it_segments segments ()
 
it_const_segments segments () const
 
Sectionas_frame ()
 
bool is_frame () const
 
void accept (Visitor &visitor) const override
 
Sectionoperator+= (ELF_SECTION_FLAGS c)
 
Sectionoperator-= (ELF_SECTION_FLAGS c)
 
- Public Member Functions inherited from LIEF::Section
 Section (std::string name)
 
Sectionoperator= (const Section &)
 
 Section (const Section &)
 
virtual std::string name () const
 section's name
 
virtual const std::string & fullname () const
 Return the complete section's name which might trailing (0) bytes.
 
virtual uint64_t virtual_address () const
 Address where the section should be mapped.
 
virtual void virtual_address (uint64_t virtual_address)
 
virtual void name (const std::string &name)
 Change the section's name.
 
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 (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
 

Additional Inherited Members

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

Detailed Description

Class wich represents an ELF Section.

Member Function Documentation

◆ accept()

void LIEF::ELF::Section::accept ( Visitor visitor) const
overridevirtual

Implements LIEF::Object.

◆ content() [1/2]

span< const uint8_t > LIEF::ELF::Section::content ( ) const
overridevirtual

Section's content.

Reimplemented from LIEF::Section.

◆ content() [2/2]

void LIEF::ELF::Section::content ( const std::vector< uint8_t > &  data)
overridevirtual

Set section content.

Reimplemented from LIEF::Section.

◆ entry_size()

uint64_t LIEF::ELF::Section::entry_size ( ) const

This function returns the size of an element in the case of a section that contains an array.

For instance, the .dynamic section contains an array of DynamicEntry. As the size of the raw C structure of this entry is 0x10 (sizeof(Elf64_Dyn)) in a ELF64, the entry_size is set to this value.

◆ file_offset()

uint64_t LIEF::ELF::Section::file_offset ( ) const
See also
offset

◆ has()

bool LIEF::ELF::Section::has ( ELF_SECTION_FLAGS  flag) const

True if the section has the given flag

Parameters
[in]flagflag to test

◆ offset() [1/2]

uint64_t LIEF::ELF::Section::offset ( ) const
overridevirtual

Offset in the binary.

Reimplemented from LIEF::Section.

◆ offset() [2/2]

void LIEF::ELF::Section::offset ( uint64_t  offset)
overridevirtual

Reimplemented from LIEF::Section.

◆ original_size()

uint64_t LIEF::ELF::Section::original_size ( ) const

Original size of the section's data.

This value is used by the ELF::Builder to determines if it needs to be relocated to avoid an override of the data

◆ size() [1/2]

uint64_t LIEF::ELF::Section::size ( ) const
overridevirtual

section's size (size in the binary, not the virtual size)

Reimplemented from LIEF::Section.

◆ size() [2/2]

void LIEF::ELF::Section::size ( uint64_t  size)
overridevirtual

Change the section size.

Reimplemented from LIEF::Section.


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