ROSE 0.11.145.134
Public Member Functions | Static Public Member Functions | List of all members
Rose::BinaryAnalysis::RelativeVirtualAddress Class Reference

Description

Optionally bound relative virtual address.

A relative virtual address (RVA) is an address which is an offset from the file's base address. The file's base address is normally found in a file header structure.

This object stores an RVA as either the offset from the file's base address, or as an offset from a specified section's preferred mapping virtual address. The latter case is useful when a section's address might change later.

Definition at line 22 of file RelativeVirtualAddress.h.

#include <Rose/BinaryAnalysis/RelativeVirtualAddress.h>

Public Member Functions

 RelativeVirtualAddress ()
 Create a zero RVA not linked to any section.
 
 RelativeVirtualAddress (const rose_addr_t rva, SgAsmGenericSection *=nullptr)
 Conversion from numeric RVA.
 
 RelativeVirtualAddress (const RelativeVirtualAddress &)
 Copy constructor.
 
RelativeVirtualAddress operator= (const RelativeVirtualAddress &)
 Assignment operator.
 
bool isBound () const
 Determines whether this instance is associated with a file section.
 
rose_addr_t rva () const
 Returns the offset.
 
RelativeVirtualAddressrva (rose_addr_t rva)
 Assign a new RVA without adjusting the bound section.
 
SgAsmGenericSectionboundSection () const
 Returns the section to which this RVA is bound.
 
RelativeVirtualAddressbindSection (SgAsmGenericSection *)
 Changes the section binding.
 
RelativeVirtualAddressbindBestSection (SgAsmGenericHeader *)
 Binds this RVA to the best available section from the specified file header.
 
Sawyer::Optional< rose_addr_t > va () const
 Return the absolute address if known.
 
Sawyer::Optional< rose_addr_t > boundOffset () const
 Returns an offset from the currently bound section.
 
rose_addr_t offsetFrom (SgAsmGenericSection *) const
 Returns an offset relative to the specified section.
 
void increment (rose_addr_t amount)
 Increment the address by the specified amount, keeping it attached to the same (if any) section.
 
std::string toString () const
 Convert to a string representation.
 
bool is_bound () const
 
rose_addr_t get_rva () const
 
RelativeVirtualAddressset_rva (rose_addr_t rva)
 
SgAsmGenericSectionget_section () const
 
RelativeVirtualAddressset_section (SgAsmGenericSection *)
 
RelativeVirtualAddressbind (SgAsmGenericHeader *)
 
rose_addr_t get_va () const
 
rose_addr_t get_rel () const
 
rose_addr_t get_rel (SgAsmGenericSection *)
 
std::string to_string () const
 

Static Public Member Functions

static RelativeVirtualAddress sectionRelative (SgAsmGenericSection *, rose_addr_t sectionOffset)
 Constructs a new instance from a section and offset.
 
static RelativeVirtualAddress section_relative (SgAsmGenericSection *, rose_addr_t)
 

Constructor & Destructor Documentation

◆ RelativeVirtualAddress()

Rose::BinaryAnalysis::RelativeVirtualAddress::RelativeVirtualAddress ( const rose_addr_t  rva,
SgAsmGenericSection = nullptr 
)

Conversion from numeric RVA.

The new instance is constructed with the specified RVA and section. The rva is relative to the base address of the file header. The section is optional, and if present then the new instance is bound to that section.

Member Function Documentation

◆ sectionRelative()

static RelativeVirtualAddress Rose::BinaryAnalysis::RelativeVirtualAddress::sectionRelative ( SgAsmGenericSection ,
rose_addr_t  sectionOffset 
)
static

Constructs a new instance from a section and offset.

The RVA is computed by adding the specified offset to the section's preferred mapping address. The returned instance is bound to the section, which must not be null.

◆ rva() [1/2]

rose_addr_t Rose::BinaryAnalysis::RelativeVirtualAddress::rva ( ) const

Returns the offset.

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 instance may be unbound.

Referenced by Rose::BinaryAnalysis::ByteOrder::hostToBe(), and Rose::BinaryAnalysis::ByteOrder::hostToLe().

◆ rva() [2/2]

RelativeVirtualAddress & Rose::BinaryAnalysis::RelativeVirtualAddress::rva ( rose_addr_t  rva)

Assign a new RVA without adjusting the bound section.

This object will store the new RVA. The binding to a section is not modified by this function.

◆ bindSection()

RelativeVirtualAddress & Rose::BinaryAnalysis::RelativeVirtualAddress::bindSection ( SgAsmGenericSection )

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 have a preferred mapping address.

◆ bindBestSection()

RelativeVirtualAddress & Rose::BinaryAnalysis::RelativeVirtualAddress::bindBestSection ( SgAsmGenericHeader )

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.

◆ va()

Sawyer::Optional< rose_addr_t > Rose::BinaryAnalysis::RelativeVirtualAddress::va ( ) const

Return the absolute address if known.

The absolute address is created by adding this RVA's numeric value to the base address associated with the bound section.

◆ boundOffset()

Sawyer::Optional< rose_addr_t > Rose::BinaryAnalysis::RelativeVirtualAddress::boundOffset ( ) const

Returns an offset from the currently bound section.

Returns this address with respect to the beginning of the bound section. If no section is bound then nothing is returned.

◆ offsetFrom()

rose_addr_t Rose::BinaryAnalysis::RelativeVirtualAddress::offsetFrom ( SgAsmGenericSection ) const

Returns an offset relative to the specified section.

The specified section must be mapped to a VA.

◆ toString()

std::string Rose::BinaryAnalysis::RelativeVirtualAddress::toString ( ) 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.


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