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

Class which represents a LOAD_COMMAND_TYPES::LC_SEGMENT / LOAD_COMMAND_TYPES::LC_SEGMENT_64 command. More...

#include <SegmentCommand.hpp>

Inheritance diagram for LIEF::MachO::SegmentCommand:
Inheritance graph
[legend]
Collaboration diagram for LIEF::MachO::SegmentCommand:
Collaboration graph
[legend]

Public Types

using content_t = std::vector<uint8_t>
 
using sections_t = std::vector<std::unique_ptr<Section>>
 Internal container for storing Mach-O Section.
 
using it_sections = ref_iterator<sections_t&, Section*>
 Iterator which outputs Section&.
 
using it_const_sections = const_ref_iterator<const sections_t&, const Section*>
 Iterator which outputs const Section&.
 
using relocations_t = std::vector<std::unique_ptr<Relocation>>
 Internal container for storing Mach-O Relocation.
 
using it_relocations = ref_iterator<relocations_t&, Relocation*>
 Iterator which outputs Relocation&.
 
using it_const_relocations = const_ref_iterator<const relocations_t&, const Relocation*>
 Iterator which outputs const Relocation&.
 
- Public Types inherited from LIEF::MachO::LoadCommand
using raw_t = std::vector<uint8_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

 SegmentCommand (const details::segment_command_32 &cmd)
 
 SegmentCommand (const details::segment_command_64 &cmd)
 
SegmentCommandoperator= (SegmentCommand other)
 
 SegmentCommand (const SegmentCommand &copy)
 
 SegmentCommand (std::string name, content_t content)
 
 SegmentCommand (std::string name)
 
void swap (SegmentCommand &other)
 
SegmentCommandclone () const override
 
const std::string & name () const
 Name of the segment (e.g. __TEXT)
 
uint64_t virtual_address () const
 Absolute virtual base address of the segment.
 
uint64_t virtual_size () const
 Virtual size of the segment.
 
uint64_t file_size () const
 Size of this segment in the binary file.
 
uint64_t file_offset () const
 Offset of the data of this segment in the file.
 
uint32_t max_protection () const
 The maximum of protections for this segment (cf. VM_PROTECTIONS)
 
uint32_t init_protection () const
 The initial protections of this segment (cf. VM_PROTECTIONS)
 
uint32_t numberof_sections () const
 The number of sections associated with this segment.
 
uint32_t flags () const
 Flags associated with this segment (cf. MACHO_SEGMENTS_FLAGS)
 
it_sections sections ()
 Return an iterator over the MachO::Section linked to this segment.
 
it_const_sections sections () const
 
it_relocations relocations ()
 Return an iterator over the MachO::Relocation linked to this segment.
 
it_const_relocations relocations () const
 
const Sectionget_section (const std::string &name) const
 Get the section with the given name.
 
Sectionget_section (const std::string &name)
 
span< const uint8_t > content () const
 The raw content of this segment.
 
int8_t index () const
 The original index of this segment.
 
void name (const std::string &name)
 
void virtual_address (uint64_t virtual_address)
 
void virtual_size (uint64_t virtual_size)
 
void file_offset (uint64_t file_offset)
 
void file_size (uint64_t file_size)
 
void max_protection (uint32_t max_protection)
 
void init_protection (uint32_t init_protection)
 
void numberof_sections (uint32_t nb_section)
 
void flags (uint32_t flags)
 
void content (content_t data)
 
Sectionadd_section (const Section &section)
 Add a new section in this segment.
 
void remove_all_sections ()
 Remove all the sections linked to this segment.
 
bool has (const Section &section) const
 Check if the current segment embeds the given section.
 
bool has_section (const std::string &section_name) const
 Check if the current segment embeds the given section name.
 
std::ostream & print (std::ostream &os) const override
 
void accept (Visitor &visitor) const override
 
- Public Member Functions inherited from LIEF::MachO::LoadCommand
 LoadCommand (const details::load_command &command)
 
 LoadCommand (LOAD_COMMAND_TYPES type, uint32_t size)
 
LoadCommandoperator= (LoadCommand copy)
 
 LoadCommand (const LoadCommand &copy)
 
void swap (LoadCommand &other)
 
LOAD_COMMAND_TYPES command () const
 Command type.
 
uint32_t size () const
 Size of the command (should be greather than sizeof(load_command))
 
span< const uint8_t > data () const
 Raw command.
 
uint64_t command_offset () const
 Offset of the command within the Load Command Table
 
void data (const raw_t &data)
 
void command (LOAD_COMMAND_TYPES command)
 
void size (uint32_t size)
 
void command_offset (uint64_t offset)
 
- 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
 

Static Public Member Functions

static bool classof (const LoadCommand *cmd)
 
- Static Public Member Functions inherited from LIEF::MachO::LoadCommand
static bool is_linkedit_data (const LoadCommand &cmd)
 

Detailed Description

Class which represents a LOAD_COMMAND_TYPES::LC_SEGMENT / LOAD_COMMAND_TYPES::LC_SEGMENT_64 command.

Member Function Documentation

◆ accept()

void LIEF::MachO::SegmentCommand::accept ( Visitor & visitor) const
overridevirtual

Reimplemented from LIEF::MachO::LoadCommand.

◆ clone()

SegmentCommand * LIEF::MachO::SegmentCommand::clone ( ) const
overridevirtual

Reimplemented from LIEF::MachO::LoadCommand.

◆ print()

std::ostream & LIEF::MachO::SegmentCommand::print ( std::ostream & os) const
overridevirtual

Reimplemented from LIEF::MachO::LoadCommand.

◆ relocations()

it_relocations LIEF::MachO::SegmentCommand::relocations ( )

Return an iterator over the MachO::Relocation linked to this segment.

For Mach-O executable or library this iterator should be empty as the relocations are managed by the Dyld::rebase_opcodes. On the other hand, for object files (.o) this iterator should not be empty


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