ROSE  0.11.145.0
Public Member Functions | Static Public Member Functions | List of all members
rose_rva_t Class Reference

Description

A relative virtual address optionally associated with a SgAsmSection.

A relative virtual addresses (RVA) is an offset from the base virtual address (base_va) stored in a file header (SgAsmGenericHeader). RVAs can either be stored as a simple numeric offset or they can be tied to the mapped address of some file section (SgAsmGenericSection). The rose_addr_t (a typedef for uint64_t) can be used in the former case, and the rose_rva_t class can be used in the latter.

Each rose_rva_t instance has an RVA represented by a rose_rva_t which can be adjusted via get_rva() and set_rva(). The rose_rva_t instance can optionally be bound to a generic section so that if the mapping address of the section changes, the value returned by get_rva() will be similarly adjusted. The RVA is usually a positive offset from the bound section, but is not required to be so.

Definition at line 8423 of file Cxx_Grammar.h.

Public Member Functions

 rose_rva_t ()
 Create a zero RVA not linked to any section. More...
 
 rose_rva_t (const rose_rva_t &)
 Copy constructor. More...
 
rose_rva_t operator= (const rose_rva_t &)
 Assignment. More...
 
 rose_rva_t (rose_addr_t rva, SgAsmGenericSection *section=nullptr)
 Conversion from numeric RVA. More...
 
bool is_bound () const
 Determines whether this RVA is associated with a file section. More...
 
rose_addr_t get_rva () const
 Returns the numeric RVA. More...
 
rose_rva_tset_rva (rose_addr_t rva)
 Resets this RVA to a new value without unbinding from a section. More...
 
SgAsmGenericSectionget_section () const
 Returns the section with which this RVA is associated. More...
 
rose_rva_tset_section (SgAsmGenericSection *section)
 Changes the section binding. More...
 
rose_rva_tbind (SgAsmGenericHeader *)
 Binds this RVA to the best available section from the specified file header. More...
 
rose_addr_t get_va () const
 Return the absolute address if known. More...
 
rose_addr_t get_rel () const
 Returns an offset from the currently bound section. More...
 
rose_addr_t get_rel (SgAsmGenericSection *)
 Returns an offset relative to the specified section. More...
 
void increment (rose_addr_t amount)
 Increment the address by the specified amount, keeping it attached to the same (if any) section. More...
 
std::string to_string () const
 Convert to a string representation. More...
 

Static Public Member Functions

static rose_rva_t section_relative (SgAsmGenericSection *section, rose_addr_t offset)
 Class method to construct a new RVA which is an offset from the beginning of a section. More...
 

Constructor & Destructor Documentation

rose_rva_t::rose_rva_t ( )

Create a zero RVA not linked to any section.

Definition at line 34 of file Rva.C.

Referenced by section_relative().

rose_rva_t::rose_rva_t ( const rose_rva_t other)

Copy constructor.

Definition at line 50 of file Rva.C.

rose_rva_t::rose_rva_t ( rose_addr_t  rva,
SgAsmGenericSection section = nullptr 
)

Conversion from numeric RVA.

The new rose_rva_t is constructed with the specified RVA and section. The RVA is relative to the base_va of the (possibly implied) file header. The section is optional.

Definition at line 41 of file Rva.C.

References set_section().

Member Function Documentation

rose_rva_t rose_rva_t::operator= ( const rose_rva_t other)

Assignment.

Definition at line 58 of file Rva.C.

rose_rva_t rose_rva_t::section_relative ( SgAsmGenericSection section,
rose_addr_t  offset 
)
static

Class method to construct a new RVA which is an offset from the beginning of a section.

The returned RVA is bound to the supplied section.

Definition at line 68 of file Rva.C.

References SgAsmGenericSection::get_mapped_preferred_rva(), SgAsmGenericSection::is_mapped(), and rose_rva_t().

bool rose_rva_t::is_bound ( ) const

Determines whether this RVA is associated with a file section.

Definition at line 78 of file Rva.C.

rose_addr_t rose_rva_t::get_rva ( ) const

Returns the numeric RVA.

The returned value is an address relative to a base address stored in a (implied) file header. The file header is not actually referenced, thus this rose_rva_t may be unbound.

Definition at line 86 of file Rva.C.

References SgAsmGenericSection::get_mapped_preferred_rva(), and SgAsmGenericSection::is_mapped().

Referenced by bind(), get_rel(), and to_string().

rose_rva_t & rose_rva_t::set_rva ( rose_addr_t  rva)

Resets this RVA to a new value without unbinding from a section.

The modified RVA is remains bound to the same section as before this call. The new RVA is allowed to be less than the beginning of the bound section.

Definition at line 99 of file Rva.C.

References SgAsmGenericSection::get_mapped_preferred_rva(), and SgAsmGenericSection::is_mapped().

SgAsmGenericSection * rose_rva_t::get_section ( ) const

Returns the section with which this RVA is associated.

Definition at line 111 of file Rva.C.

Referenced by to_string().

rose_rva_t & rose_rva_t::set_section ( SgAsmGenericSection new_section)

Changes the section binding.

This RVA is unbound from its previous section and bound to the new section. The numeric value of this RVA does not change as a result. If not null, the new_section must be mapped to a VA.

Definition at line 119 of file Rva.C.

References SgAsmGenericSection::get_mapped_preferred_rva(), and SgAsmGenericSection::is_mapped().

Referenced by bind(), and rose_rva_t().

rose_rva_t & rose_rva_t::bind ( SgAsmGenericHeader fhdr)

Binds this RVA to the best available section from the specified file header.

The numeric value of the RVA is not changed by this operation. The section is selected to be the mapped section that most specifically includes this RVA.

Definition at line 135 of file Rva.C.

References SgAsmGenericHeader::get_base_va(), SgAsmGenericHeader::get_best_section_by_va(), get_rva(), and set_section().

rose_addr_t rose_rva_t::get_va ( ) const

Return the absolute address if known.

The absolute address is created by adding this RVA's numeric value to the base_va associated with the bound section. If no section is bound to this rose_rva_t, then the RVA is returned instead.

Definition at line 145 of file Rva.C.

References SgAsmGenericSection::get_mapped_actual_va(), and SgAsmGenericSection::is_mapped().

Referenced by SgAsmGenericSection::read_content_str().

rose_addr_t rose_rva_t::get_rel ( ) const

Returns an offset from the currently bound section.

If this rose_rva_t is not bound to a section then the RVA numeric value is returned (i.e., an offset from the file header's base_va).

Definition at line 156 of file Rva.C.

Referenced by to_string().

rose_addr_t rose_rva_t::get_rel ( SgAsmGenericSection s)

Returns an offset relative to the specified section.

The specified section must be mapped to a VA.

Definition at line 163 of file Rva.C.

References SgAsmGenericSection::get_mapped_preferred_rva(), get_rva(), and SgAsmGenericSection::is_mapped().

void rose_rva_t::increment ( rose_addr_t  amount)

Increment the address by the specified amount, keeping it attached to the same (if any) section.

Definition at line 171 of file Rva.C.

std::string rose_rva_t::to_string ( ) const

Convert to a string representation.

If this RVA is unbound, then the string representation is the numeric RVA value (in hexadecimal and decimal). Otherwise the string representation contains information about the bound section.

Definition at line 179 of file Rva.C.

References SgAsmGenericSection::get_name(), get_rel(), get_rva(), get_section(), and SgAsmGenericString::get_string().


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