decompiler
1.0.0
|
Implementation of the LoadImage interface using underlying data stored in an XML format. More...
#include <loadimage_xml.hh>
Public Member Functions | |
LoadImageXml (const string &f, const Element *el) | |
Constructor. More... | |
void | open (const AddrSpaceManager *m) |
Read XML tags into the containers. More... | |
void | clear (void) |
Clear out all the caches. | |
void | encode (Encoder &encoder) const |
Encode the image to a stream. More... | |
virtual void | loadFill (uint1 *ptr, int4 size, const Address &addr) |
Get data from the LoadImage. More... | |
virtual void | openSymbols (void) const |
Prepare to read symbols. More... | |
virtual bool | getNextSymbol (LoadImageFunc &record) const |
Get the next symbol record. More... | |
virtual void | getReadonly (RangeList &list) const |
Return list of readonly address ranges. More... | |
virtual string | getArchType (void) const |
Get a string indicating the architecture type. More... | |
virtual void | adjustVma (long adjust) |
Adjust load addresses with a global offset. More... | |
Public Member Functions inherited from ghidra::LoadImage | |
LoadImage (const string &f) | |
LoadImage constructor. More... | |
virtual | ~LoadImage (void) |
LoadImage destructor. More... | |
const string & | getFileName (void) const |
Get the name of the LoadImage. More... | |
virtual void | closeSymbols (void) const |
Stop reading symbols. More... | |
virtual void | openSectionInfo (void) const |
Prepare to read section info. More... | |
virtual void | closeSectionInfo (void) const |
Stop reading section info. More... | |
virtual bool | getNextSection (LoadImageSection &sec) const |
Get info on the next section. More... | |
uint1 * | load (int4 size, const Address &addr) |
Load a chunk of image. More... | |
Private Member Functions | |
void | pad (void) |
Make sure every chunk is followed by at least 512 bytes of pad. | |
Private Attributes | |
const Element * | rootel |
The root XML element. | |
string | archtype |
The architecture string. | |
const AddrSpaceManager * | manage |
Manager of addresses. | |
set< Address > | readonlyset |
Starting address of read-only chunks. | |
map< Address, vector< uint1 > > | chunk |
Chunks of image data, mapped by address. | |
map< Address, string > | addrtosymbol |
Symbols sorted by address. | |
map< Address, string >::const_iterator | cursymbol |
Current symbol being reported. | |
Additional Inherited Members | |
Protected Attributes inherited from ghidra::LoadImage | |
string | filename |
Name of the loadimage. | |
Implementation of the LoadImage interface using underlying data stored in an XML format.
The image data is stored in an XML file in a <binaryimage> file. The data is encoded in <bytechunk> and potentially <symbol> files.
ghidra::LoadImageXml::LoadImageXml | ( | const string & | f, |
const Element * | el | ||
) |
Constructor.
f | is the (path to the) underlying XML file |
el | is the parsed form of the file |
References archtype, ghidra::LoadImage::filename, ghidra::Element::getAttributeValue(), ghidra::Element::getName(), manage, and rootel.
|
virtual |
Adjust load addresses with a global offset.
Most load image formats automatically encode information about the true loading address(es) for the data in the image. But if this is missing or incorrect, this routine can be used to make a global adjustment to the load address. Only one adjustment is made across all addresses in the image. The offset passed to this method is added to the stored or default value for any address queried in the image. This is most often used in a raw binary file format. In this case, the entire executable file is intended to be read straight into RAM, as one contiguous chunk, in order to be executed. In the absence of any other info, the first byte of the image file is loaded at offset 0. This method then would adjust the load address of the first byte.
adjust | is the offset amount to be added to default values |
Implements ghidra::LoadImage.
References ghidra::AddrSpace::addressToByte(), addrtosymbol, chunk, and ghidra::AddrSpace::getWordSize().
Referenced by getArchType().
void ghidra::LoadImageXml::encode | ( | Encoder & | encoder | ) | const |
Encode the image to a stream.
Encode the byte chunks and symbols as elements
encoder | is the stream encoder |
References addrtosymbol, archtype, chunk, ghidra::Encoder::closeElement(), ghidra::Encoder::openElement(), readonlyset, ghidra::Encoder::writeBool(), and ghidra::Encoder::writeString().
|
inlinevirtual |
Get a string indicating the architecture type.
The load image class is intended to be a generic front-end to the large variety of load formats in use. This method should return a string that identifies the particular architecture this particular image is intended to run on. It is currently the responsibility of any derived LoadImage class to establish a format for this string, but it should generally contain some indication of the operating system and the processor.
Implements ghidra::LoadImage.
References adjustVma(), and archtype.
|
virtual |
Get the next symbol record.
This method is used to read out an individual symbol record, LoadImageFunc, from the load image. Right now, the only information that can be read out are function starts and the associated function name. This method can be called repeatedly to iterate through all the symbols, until it returns false. This indicates the end of the symbols.
record | is a reference to the symbol record to be filled in |
Reimplemented from ghidra::LoadImage.
References ghidra::LoadImageFunc::address, addrtosymbol, cursymbol, and ghidra::LoadImageFunc::name.
|
virtual |
Return list of readonly address ranges.
This method should read out information about all address ranges within the load image that are known to be readonly. This method is intended to be called only once, so all information should be written to the passed RangeList object.
list | is where readonly info will get put |
Reimplemented from ghidra::LoadImage.
References chunk, ghidra::RangeList::insertRange(), and readonlyset.
|
virtual |
Get data from the LoadImage.
This is the core routine of a LoadImage. Given a particular address range, this routine retrieves the exact byte values that are stored at that address when the executable is loaded into RAM. The caller must supply a pre-allocated array of bytes where the returned bytes should be stored. If the requested address range does not exist in the image, or otherwise can't be retrieved, this method throws an DataUnavailError exception.
ptr | points to where the resulting bytes will be stored |
size | is the number of bytes to retrieve from the image |
addr | is the starting address of the bytes to retrieve |
Implements ghidra::LoadImage.
References chunk, ghidra::Address::overlap(), and ghidra::Address::printRaw().
void ghidra::LoadImageXml::open | ( | const AddrSpaceManager * | m | ) |
Read XML tags into the containers.
m | is for looking up address space |
References addrtosymbol, chunk, ghidra::XmlDecode::closeElement(), ghidra::AddrSpace::decodeAttributes(), ghidra::XmlDecode::getNextAttributeId(), manage, ghidra::XmlDecode::openElement(), pad(), ghidra::XmlDecode::readBool(), readonlyset, ghidra::XmlDecode::readSpace(), ghidra::XmlDecode::readString(), ghidra::XmlDecode::rewindAttributes(), and rootel.
|
virtual |
Prepare to read symbols.
This routine should read in and parse any symbol information that the load image contains about executable. Once this method is called, individual symbol records are read out using the getNextSymbol() method.
Reimplemented from ghidra::LoadImage.
References addrtosymbol, and cursymbol.