ROSE
0.9.6a
|
A relative virtual address optionally associated with a SgAsmSection. More...
#include <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=NULL) | |
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_t & | set_rva (rose_addr_t rva) |
Resets this RVA to a new value without unbinding from a section. More... | |
SgAsmGenericSection * | get_section () const |
Returns the section with which this RVA is associated. More... | |
rose_rva_t & | set_section (SgAsmGenericSection *section) |
Changes the section binding. More... | |
rose_rva_t & | bind (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... | |
Private Attributes | |
rose_addr_t | addr |
SgAsmGenericSection * | section |
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 6316 of file Cxx_Grammar.h.
rose_rva_t::rose_rva_t | ( | ) |
Create a zero RVA not linked to any section.
Definition at line 33 of file Rva.C.
Referenced by section_relative().
rose_rva_t::rose_rva_t | ( | const rose_rva_t & | other) |
rose_rva_t::rose_rva_t | ( | rose_addr_t | rva, |
SgAsmGenericSection * | section = NULL |
||
) |
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 40 of file Rva.C.
References addr, rva, and set_section().
rose_rva_t rose_rva_t::operator= | ( | const rose_rva_t & | other) |
|
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 67 of file Rva.C.
References SgAsmGenericSection::get_mapped_preferred_rva(), SgAsmGenericSection::is_mapped(), offset, rose_rva_t(), and rva.
bool rose_rva_t::is_bound | ( | ) | const |
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 85 of file Rva.C.
References addr, SgAsmGenericSection::get_mapped_preferred_rva(), SgAsmGenericSection::is_mapped(), rva, and section.
Referenced by bind(), SgAsmPEFileHeader::create_table_sections(), SgAsmPEExportDirectory::ctor(), SgAsmPEImportItem::dump(), SgAsmPEImportDirectory::encode(), SgAsmElfDynamicSection::finish_parsing(), get_rel(), Partitioner::mark_eh_frames(), operator!=(), operator+(), operator-(), operator<(), operator<=(), operator==(), operator>(), operator>=(), SgAsmElfFileHeader::parse(), SgAsmElfDynamicSection::parse(), SgAsmPEExportSection::parse(), SgAsmPEImportDirectory::parse(), SgAsmPEImportDirectory::parse_ilt_iat(), SgAsmPEImportDirectory::reallocate(), to_string(), SgAsmPEImportDirectory::unparse(), and SgAsmPEImportDirectory::unparse_ilt_iat().
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 98 of file Rva.C.
References addr, SgAsmGenericSection::get_mapped_preferred_rva(), SgAsmGenericSection::is_mapped(), rva, and section.
SgAsmGenericSection * rose_rva_t::get_section | ( | ) | const |
Returns the section with which this RVA is associated.
Definition at line 110 of file Rva.C.
References section.
Referenced by SgAsmElfDynamicSection::finish_parsing(), SgAsmPEImportDirectory::parse(), SgAsmPEImportDirectory::reallocate(), to_string(), SgAsmPEImportDirectory::unparse(), and SgAsmPEImportDirectory::unparse_ilt_iat().
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 118 of file Rva.C.
References addr, SgAsmGenericSection::get_mapped_preferred_rva(), SgAsmGenericSection::is_mapped(), and section.
Referenced by bind(), SgAsmPEFileHeader::create_table_sections(), SgAsmPEExportDirectory::ctor(), 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 134 of file Rva.C.
References SgAsmGenericHeader::get_base_va(), SgAsmGenericHeader::get_best_section_by_va(), get_rva(), and set_section().
Referenced by SgAsmElfFileHeader::parse(), SgAsmPEExportSection::parse(), and SgAsmPEImportDirectory::parse().
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 144 of file Rva.C.
References addr, SgAsmGenericSection::get_base_va(), SgAsmGenericSection::get_mapped_preferred_rva(), SgAsmGenericSection::is_mapped(), and section.
Referenced by SgAsmPEExportDirectory::ctor(), SgAsmPEImportItem::get_iat_entry_va(), SgAsmPEExportSection::parse(), SgAsmPEImportDirectory::parse(), SgAsmPEImportDirectory::parse_ilt_iat(), SgAsmGenericSection::read_content(), SgAsmGenericSection::read_content_str(), and SgAsmIntegerValueExpression::virtual_address().
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 155 of file Rva.C.
References addr.
Referenced by SgAsmPEImportSection::reallocate(), SgAsmPEImportSection::reallocate_iats(), to_string(), SgAsmPEImportDirectory::unparse(), and SgAsmPEImportDirectory::unparse_ilt_iat().
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 162 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 170 of file Rva.C.
References addr.
Referenced by SgAsmPEImportSection::reallocate(), SgAsmPEImportDirectory::reallocate(), SgAsmPEImportSection::reallocate_iats(), and SgAsmPEImportDirectory::unparse_ilt_iat().
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 178 of file Rva.C.
References SgAsmGenericSection::get_name(), get_rel(), get_rva(), get_section(), and SgAsmGenericString::get_string().
Referenced by SgAsmPEFileHeader::dump(), SgAsmPEExportEntry::dump(), SgAsmPEImportDirectory::dump(), SgAsmPEExportDirectory::dump(), SgAsmPEImportItem::dump(), operator<<(), SgAsmPEImportDirectory::parse(), SgAsmPEImportDirectory::unparse(), and SgAsmPEImportDirectory::unparse_ilt_iat().
|
private |
Definition at line 6335 of file Cxx_Grammar.h.
Referenced by get_rel(), get_rva(), get_va(), increment(), operator=(), rose_rva_t(), set_rva(), and set_section().
|
private |
Definition at line 6336 of file Cxx_Grammar.h.
Referenced by get_rva(), get_section(), get_va(), is_bound(), operator=(), rose_rva_t(), set_rva(), and set_section().