30 #if !defined(_StExecutableImage_h_) 31 #define _StExecutableImage_h_ 33 #include "blfwk/stdafx.h" 87 inline uint32_t
endAddress()
const {
return m_address + m_length - 1; }
115 AddressFilterAction m_action;
116 uint32_t m_fromAddress;
117 uint32_t m_toAddress;
121 AddressFilter(AddressFilterAction action, uint32_t from, uint32_t to,
unsigned priority = 0)
123 , m_fromAddress(from)
125 , m_priority(priority)
130 bool matchesMemoryRegion(
const MemoryRegion ®ion)
const;
137 inline bool operator<(
const AddressFilter &other)
const {
return compare(other) == -1; }
138 inline bool operator>(
const AddressFilter &other)
const {
return compare(other) == 1; }
140 inline bool operator<=(
const AddressFilter &other)
const {
return compare(other) != 1; }
141 inline bool operator>=(
const AddressFilter &other)
const {
return compare(other) != -1; }
159 , m_imageName(imageName)
160 , m_filter(matchingFilter)
166 inline bool isError()
const {
return m_isError; }
168 inline std::string getImageName()
const {
return m_imageName; }
170 inline const AddressFilter &getMatchingFilter()
const {
return m_filter; }
173 std::string m_imageName;
190 virtual void setName(
const std::string &inName);
194 virtual std::string
getName()
const;
200 virtual void addFillRegion(uint32_t inAddress,
unsigned inLength);
204 virtual void addTextRegion(uint32_t inAddress,
const uint8_t *inData,
unsigned inLength);
245 template <
typename _T>
249 for (; it != to; ++it)
280 #endif // _StExecutableImage_h_ MemoryRegionType m_type
Memory region type.
Definition: apps/elftosb/common/StExecutableImage.h:57
const_iterator getRegionBegin() const
Return an iterator to the first region.
Definition: src/blfwk/StExecutableImage.h:215
virtual void addAddressFilter(const AddressFilter &filter)
Add a new address filter.
Definition: apps/elftosb/common/StExecutableImage.cpp:129
virtual void addFillRegion(uint32_t inAddress, unsigned inLength)
Add a region to be filled with zeroes.
Definition: apps/elftosb/common/StExecutableImage.cpp:74
uint32_t m_length
Number of bytes in this region.
Definition: apps/elftosb/common/StExecutableImage.h:59
const_iterator getRegionEnd() const
Return an iterator to the next-after-last region.
Definition: src/blfwk/StExecutableImage.h:217
StExecutableImage(int inAlignment=256)
Constructor.
Definition: apps/elftosb/common/StExecutableImage.cpp:14
unsigned m_flags
Flags for the region.
Definition: apps/elftosb/common/StExecutableImage.h:61
Region is readable.
Definition: apps/elftosb/common/StExecutableImage.h:40
A region containing data or instructions.
Definition: apps/elftosb/common/StExecutableImage.h:33
virtual ~StExecutableImage()
Destructor.
Definition: apps/elftosb/common/StExecutableImage.cpp:46
virtual void clearAddressFilters()
Remove all active filters.
Definition: apps/elftosb/common/StExecutableImage.cpp:136
Definition: apps/elftosb/common/StExecutableImage.h:127
Region to be initialized with zero bytes.
Definition: apps/elftosb/common/StExecutableImage.h:34
virtual void applyAddressFilters()
Process all active filters and perform associated actions.
Definition: apps/elftosb/common/StExecutableImage.cpp:148
int m_alignment
The required address alignment for each memory region.
Definition: apps/elftosb/common/StExecutableImage.h:241
Used to build a representation of memory regions.
Definition: apps/elftosb/common/StExecutableImage.h:27
uint32_t getEntryPoint() const
Returns the entry point address.
Definition: src/blfwk/StExecutableImage.h:232
bool hasEntryPoint() const
Returns true if an entry point has been set.
Definition: src/blfwk/StExecutableImage.h:230
virtual void addTextRegion(uint32_t inAddress, const uint8_t *inData, unsigned inLength)
Add a region containing data to be loaded.
Definition: apps/elftosb/common/StExecutableImage.cpp:93
std::string m_name
The name of the image (can be a file name, for instance).
Definition: apps/elftosb/common/StExecutableImage.h:240
Definition: apps/elftosb/common/StExecutableImage.h:90
const MemoryRegion & getRegionAtIndex(unsigned inIndex) const
Returns a reference to the region specified by inIndex.
Definition: apps/elftosb/common/StExecutableImage.cpp:110
virtual void setName(const std::string &inName)
Sets the image's name to inName.
Definition: apps/elftosb/common/StExecutableImage.cpp:61
Do nothing.
Definition: apps/elftosb/common/StExecutableImage.h:79
bool m_hasEntry
True if an entry point has been set.
Definition: apps/elftosb/common/StExecutableImage.h:242
void mergeRegions(MemoryRegion &inOldRegion, MemoryRegion &inNewRegion)
Merges two memory regions into one.
Definition: apps/elftosb/common/StExecutableImage.cpp:333
AddressFilter(AddressFilterAction action, uint32_t from, uint32_t to, unsigned priority=0)
Constructor.
Definition: src/blfwk/StExecutableImage.h:121
void addAddressFilters(_T from, _T to)
Add multiple address filters at once.
Definition: src/blfwk/StExecutableImage.h:246
MemoryRegionList m_image
The memory regions.
Definition: apps/elftosb/common/StExecutableImage.h:244
void setEntryPoint(uint32_t inEntryAddress)
Sets the entry point address.
Definition: apps/elftosb/common/StExecutableImage.h:200
AddressFilterList m_filters
List of active address filters.
Definition: apps/elftosb/common/StExecutableImage.h:245
bool operator==(const MemoryRegion &other)
Equality operator.
Definition: apps/elftosb/common/StExecutableImage.cpp:402
uint32_t endAddress() const
Calculates the address of the last byte occupied by this region.
Definition: src/blfwk/StExecutableImage.h:87
uint32_t m_address
The 32-bit start address of this region.
Definition: apps/elftosb/common/StExecutableImage.h:58
Mask to access only permissions flags for a region.
Definition: apps/elftosb/common/StExecutableImage.h:47
void insertOrMergeRegion(MemoryRegion &inRegion)
Inserts the region in sorted order or merges with one already in the image.
Definition: apps/elftosb/common/StExecutableImage.cpp:286
address_filter_exception(bool isError, std::string &imageName, const AddressFilter &matchingFilter)
Constructor.
Definition: src/blfwk/StExecutableImage.h:157
unsigned getRegionCount() const
Returns the total number of regions.
Definition: src/blfwk/StExecutableImage.h:210
MemoryRegionType
Possible types of memory regions.
Definition: apps/elftosb/common/StExecutableImage.h:31
AddressFilterAction
The possible actions for regions matching an address filter range.
Definition: apps/elftosb/common/StExecutableImage.h:77
bool isError() const
Returns true if the exception is an error. Otherwise the exception is for a warning.
Definition: src/blfwk/StExecutableImage.h:166
uint8_t * m_data
Pointer to data. Will be NULL for FILL_REGION type.
Definition: apps/elftosb/common/StExecutableImage.h:60
void cropRegionToFilter(MemoryRegion ®ion, const AddressFilter &filter)
Deletes the portion region that overlaps filter.
Definition: apps/elftosb/common/StExecutableImage.cpp:205
std::list< MemoryRegion > MemoryRegionList
A list of StExecutableImage::MemoryRegion objects.
Definition: src/blfwk/StExecutableImage.h:93
virtual std::string getName() const
Returns a copy of the image's name.
Definition: apps/elftosb/common/StExecutableImage.cpp:66
Raise a warning exception.
Definition: apps/elftosb/common/StExecutableImage.h:81
MemoryRegionList::const_iterator const_iterator
Definition: src/blfwk/StExecutableImage.h:97
Don't include the matching address range in the executable image.
Definition: apps/elftosb/common/StExecutableImage.h:82
Region is writable.
Definition: apps/elftosb/common/StExecutableImage.h:41
Definition: apps/elftosb/common/StExecutableImage.h:55
Region is read-write.
Definition: apps/elftosb/common/StExecutableImage.h:44
Region may contain executable code.
Definition: apps/elftosb/common/StExecutableImage.h:42
std::list< AddressFilter > AddressFilterList
List of StExecutableImage::AddressFilter objects.
Definition: src/blfwk/StExecutableImage.h:146
uint32_t m_entry
Entry point address.
Definition: apps/elftosb/common/StExecutableImage.h:243
Raise an error exception.
Definition: apps/elftosb/common/StExecutableImage.h:80