1 #ifndef ROSE_BinaryAnalysis_SRecord_H
2 #define ROSE_BinaryAnalysis_SRecord_H
3 #include <featureTests.h>
4 #ifdef ROSE_ENABLE_BINARY_ANALYSIS
7 namespace BinaryAnalysis {
64 std::vector<uint8_t> data_;
78 : type_(type), addr_(addr), data_(data) {}
80 : type_(type), addr_(addr), data_(buffer+0, buffer+bufsz) {}
97 static std::vector<SRecord>
parse(std::istream&);
117 unsigned accessPerms=MemoryMap::READABLE|MemoryMap::WRITABLE|MemoryMap::EXECUTABLE,
118 const std::string &newSegmentNames =
"S-Records");
129 void print(std::ostream&)
const;
164 const std::vector<uint8_t>&
data()
const {
return data_; }
165 std::vector<uint8_t>&
data() {
return data_; }
172 const std::string&
error()
const {
return error_; }
185 size_t nDataRecords_;
189 : nDataRecords_(0) {}
226 static unsigned bigEndian(
const std::vector<uint8_t> &
data,
size_t nBytes);
237 static uint8_t
checksum(
Syntax,
const std::string&,
size_t start,
size_t n);
static Sawyer::Optional< rose_addr_t > parseBigEndianInteger(const std::string &, size_t start, size_t nChars)
Parse a hexadecimal string to an unsigned integer.
const std::string & error() const
Property: record error messsage.
Motorola 16-bit count of data records.
Motorola 24-bit starting address.
static unsigned bigEndian(const std::vector< uint8_t > &data, size_t nBytes)
Convert the first few bytes of the buffer to a big-endian integer.
rose_addr_t address() const
Property: record starting address.
void print(std::ostream &) const
Print an S-Record to a stream.
SRecord & address(rose_addr_t addr)
Property: record starting address.
static SRecord parse(const std::string &)
Construct an S-Record by parsing a string.
Intel starting linear address.
Intel extended linear address.
const std::vector< uint8_t > & data() const
Property: record data.
Motorola 32-bit starting address.
Motorola data with 16-bit address.
Motorola data with 32-bit address.
RunLengthEncoding()
Default constructor.
static size_t addressNBytes(Type)
Size of address in bytes.
static SRecord parseMotorola(const std::string &)
Construct a Motorola S-Record by parsing a string.
SRecord()
Construct an empty S-Record.
Main namespace for the ROSE library.
static std::vector< SRecord > create(const MemoryMap::Ptr &, Syntax, size_t bytesPerRecord=28, size_t preferredAddrSize=4)
Create S-Records from a memory map.
Motorola data with 24-bit address.
friend std::ostream & operator<<(std::ostream &, const SRecord &)
Print an S-Record to a stream.
Motorola 24-bit count of data records.
Sawyer::Optional< rose_addr_t > executionAddress() const
Returns the execution starting address if one was specified.
Intel extended segment address.
S-Record hexadecimal data formats.
std::vector< uint8_t > & data()
Property: record data.
Syntax syntax() const
Property: syntax family.
Intel starting segment address.
static Sawyer::Optional< rose_addr_t > load(const std::vector< SRecord > &, const MemoryMap::Ptr &, bool createSegments=true, unsigned accessPerms=MemoryMap::READABLE|MemoryMap::WRITABLE|MemoryMap::EXECUTABLE, const std::string &newSegmentNames="S-Records")
Load S-Records into a memory map.
static uint8_t checksum(Syntax, const std::string &, size_t start, size_t n)
Compute a checksum for part of a record.
Motorola 16-bit starting address.
Sawyer::Optional< rose_addr_t > dataAddress(const SRecord &) const
Returns the memory address for the start of a data record, or nothing.
Motorola syntax S-Record.
SRecord & error(const std::string &error)
Property: record error messsage.
std::string toString() const
Convert an S-Record to a string.
SRecord(Type type, rose_addr_t addr, const std::vector< uint8_t > data)
Construct an S-Record with data.
static AddressIntervalSet dataAddresses(const std::vector< SRecord > &)
Addresses occupied by all data.
SRecord(Type type, rose_addr_t addr, const uint8_t *buffer, size_t bufsz)
Construct an S-Record with data.
SRecord & data(const std::vector< uint8_t > &data)
Property: record data.
Run-length encoding information.
void insert(const SRecord &)
Insert an S-Record into the data sumarized by this class.
static SRecord parseIntel(const std::string &)
Construct an Intel S-Record by parsing a string.
Type type() const
Property: record type.
SRecord & type(Type type)
Property: record type.
size_t nDataRecords() const
Number of data records seen.
rose_addr_t baseDataAddress() const
Base data address.
Syntax
Syntax of the S-Record.
Motorola vendor-specific header, usually NUL-terminated ASCII.