1#ifndef ROSE_BinaryAnalysis_Partitioner2_JumpTable_H
2#define ROSE_BinaryAnalysis_Partitioner2_JumpTable_H
3#include <featureTests.h>
4#ifdef ROSE_ENABLE_BINARY_ANALYSIS
5#include <Rose/BinaryAnalysis/Partitioner2/MemoryTable.h>
8namespace BinaryAnalysis {
9namespace Partitioner2 {
39 using Ptr = std::shared_ptr<Entries>;
42 std::vector<Address> targets_;
47 static Ptr instance();
51 const std::vector<Address>&
targets()
const;
54 size_t size()
const override;
60 Address parseEntry(
const JumpTable*,
const std::vector<uint8_t> &bytes)
const;
bool maybeAppend(const MemoryTable *, Address entryAddr, const std::vector< uint8_t > &bytes) override
Parse a table entry and append to this list if the entry is valid.
bool maybePrepend(const MemoryTable *, Address entryAddr, const std::vector< uint8_t > &bytes) override
Parse a table entry and prepend to this list if the entry is valid.
size_t size() const override
Number of entries stored.
const std::vector< Address > & targets() const
Return the targets.
Utilities for working with jump tables.
std::set< Address > uniqueTargets() const
Result: Unique target addresses parsed from the table.
JumpTablePtr Ptr
Shared ownership pointer.
EntryType
How target addresses are computed from entries.
@ ABSOLUTE
Target is entry plus (nominally zero) constant offset.
@ TABLE_RELATIVE
Like ABSOLUTE but add the table address.
PartitionerConstPtr partitioner() const
Property: Partitioner supplied to the constructor.
void attachTableToBasicBlock(const BasicBlockPtr &) const
Create a data block and attach it to the specified basic block.
Address perEntryOffset() const
Property: Offset added to each table entry when calculating the target address.
JumpTableConstPtr ConstPtr
Shared ownership pointer.
void replaceBasicBlockSuccessors(const PartitionerConstPtr &, const BasicBlockPtr &) const
Change basic block successors to be the table's targets.
AddressInterval targetLimits() const
Property: Predicate to determine whether a target is valid.
static Ptr instance(const PartitionerConstPtr &, const AddressInterval &tableLimits, size_t bytesPerEntry, Address perEntryOffset, EntryType)
Allocating constructor.
void refineTargetLimits(const BasicBlockPtr &)
Refine target limits based on a particular basic block.
const std::vector< Address > & targets() const
Result: Target addresses parsed from the table.
DataBlockPtr createDataBlock() const
Build a data block to represent the table.
void refineLocationLimits(const BasicBlockPtr &, Address probableTableAddr)
Refine the table limits based on a particular basic block.
void targetLimits(const AddressInterval &)
Property: Predicate to determine whether a target is valid.
EntryType entryType() const
Property: Entry type.
Represents the entries in the table.
Utilities for working with tables.
size_t bytesPerEntry() const
Property: Bytes per entry.
AddressInterval tableLimits() const
Property: Limits for table location.
std::shared_ptr< const JumpTable > JumpTableConstPtr
Shared-ownership pointer for JumpTable.
std::shared_ptr< JumpTable > JumpTablePtr
Shared-ownership pointer for JumpTable.
std::uint64_t Address
Address.