25 void MCModule::map(
MCAtom *NewAtom) {
26 uint64_t Begin = NewAtom->
Begin;
28 assert(Begin <= NewAtom->End &&
"Creating MCAtom with endpoints reversed?");
33 assert((I ==
atom_end() || (*I)->getBeginAddr() > NewAtom->
End)
34 &&
"Offset range already occupied!");
37 Atoms.insert(I, NewAtom);
53 void MCModule::remap(
MCAtom *Atom, uint64_t NewBegin, uint64_t NewEnd) {
57 assert(I !=
atom_end() &&
"Atom offset not found in module!");
58 assert(*I == Atom &&
"Previous atom mapping was invalid!");
66 assert((NewI ==
atom_end() || (*NewI)->getBeginAddr() > Atom->
End)
67 &&
"Offset range already occupied!");
68 Atoms.insert(NewI, Atom);
71 Atom->
Begin = NewBegin;
78 if (I !=
atom_end() && (*I)->getBeginAddr() <= Addr)
84 return const_cast<MCAtom*
>(
97 return const_cast<MCAtom*
>(
102 Functions.push_back(
new MCFunction(Name,
this));
103 return Functions.back();
110 void MCModule::splitBasicBlocksForAtom(
const MCTextAtom *
TA,
112 BBsByAtomTy::iterator
113 I = std::lower_bound(BBsByAtom.begin(), BBsByAtom.end(),
115 for (; I != BBsByAtom.end() && (*I)->getInsts() ==
TA; ++
I) {
123 assert(Atom == BB->
getInsts() &&
"Text atom doesn't back the basic block!");
124 BBsByAtomTy::iterator I = std::lower_bound(BBsByAtom.begin(),
127 for (; I != BBsByAtom.end() && (*I)->getInsts() == Atom; ++
I)
130 BBsByAtom.insert(I, BB);
138 for (FunctionListTy::iterator FI =
func_begin(),
const MCAtom * findFirstAtomAfter(uint64_t Addr) const
MCBasicBlock & createBlock(const MCTextAtom &Insts)
Create an MCBasicBlock backed by Insts and add it to this function.
An atom consisting of disassembled instructions.
static bool CompBBToAtom(MCBasicBlock *BB, const MCTextAtom *Atom)
void splitBasicBlock(MCBasicBlock *SplitBB)
Split block, mirrorring NewAtom = Insts->split(..). This moves all successors to SplitBB, and adds a fallthrough to it. SplitBB The result of splitting Insts, a basic block directly following this basic block.
const MCAtom * findAtomContaining(uint64_t Addr) const
An atom consising of a sequence of bytes.
MCFunction * createFunction(StringRef Name)
Create a new MCFunction.
MCDataAtom * createDataAtom(uint64_t Begin, uint64_t End)
Represents a function in machine code, containing MCBasicBlocks. MCFunctions are created by MCModule...
MCTextAtom * createTextAtom(uint64_t Begin, uint64_t End)
const_atom_iterator atom_end() const
const_func_iterator func_begin() const
const_func_iterator func_end() const
Basic block containing a sequence of disassembled instructions. The basic block is backed by an MCTex...
Represents a contiguous range of either instructions (a TextAtom) or data (a DataAtom). Address ranges are expressed as closed intervals.
static bool AtomComp(const MCAtom *L, uint64_t Addr)
uint64_t getEndAddr() const
Get the end address, i.e. the last one inside the atom.
A completely disassembled object file or executable. It comprises a list of MCAtom's, each representing a contiguous range of either instructions or data. An MCModule is created using MCObjectDisassembler::buildModule.
const MCTextAtom * getInsts() const
Get the backing MCTextAtom, containing the instruction sequence.
const MCFunction * getParent() const
static bool AtomCompInv(uint64_t Addr, const MCAtom *R)
const_atom_iterator atom_begin() const