diff --git a/include/fxos/disassembly.h b/include/fxos/disassembly.h index 8af8c6e..51f1e29 100644 --- a/include/fxos/disassembly.h +++ b/include/fxos/disassembly.h @@ -59,12 +59,12 @@ struct Argument }; /* A loaded and annotated instruction. */ -struct Instruction +struct OldInstruction { /* Build from instruction, cannot be nullptr. */ - Instruction(AsmInstruction const *inst); + OldInstruction(AsmInstruction const *inst); /* Build from opcode, if instruction could not be decoded. */ - Instruction(uint16_t opcode); + OldInstruction(uint16_t opcode); /* What instruction this is. Note that this does not determine all the properties below. Placement and delay slots greatly alter them. @@ -174,14 +174,14 @@ struct Disassembly // Instruction information - std::map instructions; + std::map instructions; /* Check whether an instruction is loaded at PC */ bool hasInstructionAt(uint32_t pc); /* Find an instruction by address. If the instruction is not loaded, returns nullptr, unless [allowDiscovery] is set, in which case it's loaded normally. */ - Instruction *getInstructionAt(uint32_t pc, bool allowDiscovery = false); + OldInstruction *getInstructionAt(uint32_t pc, bool allowDiscovery = false); // Function information @@ -278,7 +278,7 @@ public: bool analyzeAllInstructions(); /* Analyze a single instruction */ - virtual bool analyzeInstruction(uint32_t pc, Instruction &ins) = 0; + virtual bool analyzeInstruction(uint32_t pc, OldInstruction &ins) = 0; /* Analyze a function by following its CFG */ using FunctionPass::analyzeFunction; @@ -289,8 +289,8 @@ public: /* For custom analysis functions: enqueue successors. The update variant enqueues them even if they were already seen. */ - void enqueueSuccessors(uint32_t pc, Instruction &ins); - void updateSuccessors(uint32_t pc, Instruction &ins); + void enqueueSuccessors(uint32_t pc, OldInstruction &ins); + void updateSuccessors(uint32_t pc, OldInstruction &ins); private: Queue m_queue; diff --git a/include/fxos/passes/cfg.h b/include/fxos/passes/cfg.h index a3b9953..f3a19c3 100644 --- a/include/fxos/passes/cfg.h +++ b/include/fxos/passes/cfg.h @@ -54,7 +54,7 @@ class CfgPass: public InstructionPass { public: CfgPass(Disassembly &disasm); - bool analyzeInstruction(uint32_t pc, Instruction &inst) override; + bool analyzeInstruction(uint32_t pc, OldInstruction &inst) override; /* Explore a new function at the specified address. This method creates the function if it doesn't exist yet, explores its CFG, and generates claims diff --git a/include/fxos/passes/pcrel.h b/include/fxos/passes/pcrel.h index f02d014..8ea0c88 100644 --- a/include/fxos/passes/pcrel.h +++ b/include/fxos/passes/pcrel.h @@ -28,7 +28,7 @@ class PcrelPass: public InstructionPass { public: PcrelPass(Disassembly &disasm); - bool analyzeInstruction(uint32_t pc, Instruction &inst) override; + bool analyzeInstruction(uint32_t pc, OldInstruction &inst) override; }; } /* namespace FxOS */ diff --git a/include/fxos/passes/print.h b/include/fxos/passes/print.h index ad54356..33349fc 100644 --- a/include/fxos/passes/print.h +++ b/include/fxos/passes/print.h @@ -48,7 +48,7 @@ class PrintPass: public InstructionPass { public: PrintPass(Disassembly &disasm); - bool analyzeInstruction(uint32_t pc, Instruction &inst) override; + bool analyzeInstruction(uint32_t pc, OldInstruction &inst) override; //--- // Print pass parameters diff --git a/include/fxos/passes/syscall.h b/include/fxos/passes/syscall.h index 17d5cca..881d969 100644 --- a/include/fxos/passes/syscall.h +++ b/include/fxos/passes/syscall.h @@ -23,7 +23,7 @@ class SyscallPass: public InstructionPass { public: SyscallPass(Disassembly &disasm, OS *os); - bool analyzeInstruction(uint32_t pc, Instruction &inst) override; + bool analyzeInstruction(uint32_t pc, OldInstruction &inst) override; private: OS *m_os; diff --git a/lib/disassembly.cpp b/lib/disassembly.cpp index 9a71558..406ba82 100644 --- a/lib/disassembly.cpp +++ b/lib/disassembly.cpp @@ -38,14 +38,14 @@ Argument::Argument() syscall_id = -1; } -Instruction::Instruction(AsmInstruction const *inst): +OldInstruction::OldInstruction(AsmInstruction const *inst): inst {inst}, args {}, opcode {inst->opcode}, leader {false}, delayslot {false}, terminal {false}, jump {false}, condjump {false}, jmptarget {0xffffffff} { } -Instruction::Instruction(uint16_t opcode): +OldInstruction::OldInstruction(uint16_t opcode): inst {nullptr}, args {}, opcode {opcode}, leader {false}, delayslot {false}, terminal {false}, jump {false}, condjump {false}, jmptarget {0xffffffff} { @@ -113,7 +113,7 @@ bool Disassembly::hasInstructionAt(uint32_t pc) return this->instructions.count(pc) > 0; } -Instruction *Disassembly::getInstructionAt(uint32_t pc, bool allowDiscovery) +OldInstruction *Disassembly::getInstructionAt(uint32_t pc, bool allowDiscovery) { if(pc & 1) { FxOS_log(ERR, "reading instruction for disassembly at 0x%08x", pc); @@ -125,10 +125,10 @@ Instruction *Disassembly::getInstructionAt(uint32_t pc, bool allowDiscovery) } else if(allowDiscovery) { uint16_t opcode = this->vspace.read_u16(pc); - Instruction i(opcode); + OldInstruction i(opcode); if(insmap[opcode]) - i = Instruction(&*insmap[opcode]); + i = OldInstruction(&*insmap[opcode]); this->instructions.emplace(pc, i); return &this->instructions.at(pc); @@ -349,7 +349,7 @@ bool InstructionPass::analyzeAnonymousFunction(uint32_t pc) while(!m_queue.empty()) { uint32_t pc = m_queue.pop(); - Instruction *i = m_disasm.getInstructionAt(pc, m_allowDiscovery); + OldInstruction *i = m_disasm.getInstructionAt(pc, m_allowDiscovery); if(i != nullptr && this->analyzeInstruction(pc, *i)) this->enqueueSuccessors(pc, *i); @@ -360,7 +360,7 @@ bool InstructionPass::analyzeAnonymousFunction(uint32_t pc) return ok; } -void InstructionPass::enqueueSuccessors(uint32_t pc, Instruction &i) +void InstructionPass::enqueueSuccessors(uint32_t pc, OldInstruction &i) { if(!i.terminal && !i.jump) m_queue.enqueue(pc + 2); @@ -368,7 +368,7 @@ void InstructionPass::enqueueSuccessors(uint32_t pc, Instruction &i) m_queue.enqueue(i.jmptarget); } -void InstructionPass::updateSuccessors(uint32_t pc, Instruction &i) +void InstructionPass::updateSuccessors(uint32_t pc, OldInstruction &i) { if(!i.terminal && !i.jump) m_queue.update(pc + 2); diff --git a/lib/passes/cfg.cpp b/lib/passes/cfg.cpp index 80a2805..9b8d144 100644 --- a/lib/passes/cfg.cpp +++ b/lib/passes/cfg.cpp @@ -18,7 +18,7 @@ CfgPass::CfgPass(Disassembly &disasm): this->setAllowDiscovery(true); } -bool CfgPass::analyzeInstruction(uint32_t pc, Instruction &i) +bool CfgPass::analyzeInstruction(uint32_t pc, OldInstruction &i) { /* Don't explore successors if the instruction cannot be decoded, not even pc+2. This will prevent wild overshoot. */ @@ -45,7 +45,7 @@ bool CfgPass::analyzeInstruction(uint32_t pc, Instruction &i) jmptarget = (pc + 4) + args[0].disp; /* Make the target of the jump a leader */ - Instruction &target = *m_disasm.getInstructionAt(jmptarget, true); + OldInstruction &target = *m_disasm.getInstructionAt(jmptarget, true); target.leader = true; /* Check that it's not in a delay slot */ @@ -68,7 +68,7 @@ bool CfgPass::analyzeInstruction(uint32_t pc, Instruction &i) } /* If it has a delay slot, create it at the next instruction */ else if(i.inst->hasDelaySlot()) { - Instruction &slot = *m_disasm.getInstructionAt(pc + 2, true); + OldInstruction &slot = *m_disasm.getInstructionAt(pc + 2, true); if(slot.leader) throw std::logic_error(format( "0x%08x is a leader and also a delay" @@ -111,7 +111,7 @@ bool CfgPass::exploreFunction(uint32_t pc) /* Look for call targets */ for(uint32_t pc: m_claimedInstructions) { - Instruction const *ci = m_disasm.getInstructionAt(pc); + OldInstruction const *ci = m_disasm.getInstructionAt(pc); if(!ci) continue; AsmInstruction const &i = *ci->inst; diff --git a/lib/passes/pcrel.cpp b/lib/passes/pcrel.cpp index 0e3248d..5a3f77c 100644 --- a/lib/passes/pcrel.cpp +++ b/lib/passes/pcrel.cpp @@ -14,7 +14,7 @@ PcrelPass::PcrelPass(Disassembly &disasm): InstructionPass(disasm) { } -bool PcrelPass::analyzeInstruction(uint32_t pc, Instruction &ci) +bool PcrelPass::analyzeInstruction(uint32_t pc, OldInstruction &ci) { AsmInstruction const *i = ci.inst; if(!i) diff --git a/lib/passes/print.cpp b/lib/passes/print.cpp index c40a1e9..1d58221 100644 --- a/lib/passes/print.cpp +++ b/lib/passes/print.cpp @@ -26,7 +26,7 @@ PrintPass::PrintPass(Disassembly &disasm): m_symtables.push_back(disasm.vspace.symbols); } -bool PrintPass::analyzeInstruction(uint32_t pc, Instruction &i) +bool PrintPass::analyzeInstruction(uint32_t pc, OldInstruction &i) { /* Ellipsis if there is a gap since last instruction */ diff --git a/lib/passes/syscall.cpp b/lib/passes/syscall.cpp index b404954..6e266e6 100644 --- a/lib/passes/syscall.cpp +++ b/lib/passes/syscall.cpp @@ -14,7 +14,7 @@ SyscallPass::SyscallPass(Disassembly &disasm, OS *os): { } -bool SyscallPass::analyzeInstruction(uint32_t pc, Instruction &ci) +bool SyscallPass::analyzeInstruction(uint32_t pc, OldInstruction &ci) { /* Nothing to do if no syscall table is provided! */ if(!m_os)