util: Added disassembler using objdump tool.
The disassembler disassembles an elf file with an external objdump tool. The architecture specific objdump must be configured via cmake (ARCH_TOOL_PREFIX), e.g. arm-none-eabi- for arm-none-eabi-objdump.
This commit is contained in:
@ -20,6 +20,7 @@
|
||||
|
||||
#include "campaign.hpp"
|
||||
#include "kesoref.pb.h"
|
||||
#include "util/Disassembler.hpp"
|
||||
|
||||
using namespace std;
|
||||
using namespace fail;
|
||||
@ -79,6 +80,7 @@ void handleMemoryAccessEvent(KesoRefExperimentData& param, const fail::MemAccess
|
||||
|
||||
bool KESOrefs::run()
|
||||
{
|
||||
m_dis.init();
|
||||
//******* Boot, and store state *******//
|
||||
m_log << "STARTING EXPERIMENT" << endl;
|
||||
#if SAFESTATE // define SS (SafeState) when building: make -DSS
|
||||
|
||||
@ -14,6 +14,7 @@ class KESOrefs : public fail::ExperimentFlow {
|
||||
fail::Logger m_log;
|
||||
fail::MemoryManager& m_mm;
|
||||
fail::ElfReader m_elf;
|
||||
fail::Disassembler m_dis;
|
||||
|
||||
void printEIP();
|
||||
void setupExitBPs(const std::string&);
|
||||
|
||||
@ -15,13 +15,14 @@
|
||||
#include "sal/Listener.hpp"
|
||||
|
||||
#include <string>
|
||||
|
||||
using namespace std;
|
||||
using namespace fail;
|
||||
|
||||
|
||||
bool VEZSExperiment::run()
|
||||
{
|
||||
MemoryManager& mm = simulator.getMemoryManager();
|
||||
|
||||
//m_elf.printDemangled();
|
||||
m_log << "STARTING EXPERIMENT" << endl;
|
||||
m_log << "Instruction Pointer: 0x" << hex << simulator.getCPU(0).getInstructionPointer() << endl;
|
||||
// Test register access
|
||||
@ -30,34 +31,30 @@ bool VEZSExperiment::run()
|
||||
|
||||
reg = simulator.getCPU(0).getRegister(RI_R2);
|
||||
m_log << "Register R2: 0x" << hex << simulator.getCPU(0).getRegisterContent(reg) << endl;
|
||||
simulator.getCPU(0).setRegisterContent(reg, 0x23);
|
||||
|
||||
reg = simulator.getCPU(0).getRegister(RI_R3);
|
||||
m_log << "Register R3: 0x" << hex << simulator.getCPU(0).getRegisterContent(reg) << endl;
|
||||
|
||||
simulator.terminate();
|
||||
|
||||
// STOP HERE
|
||||
|
||||
|
||||
|
||||
// Test Memory access
|
||||
address_t targetaddress = 0x12345678;
|
||||
MemoryManager& mm = simulator.getMemoryManager();
|
||||
mm.setByte(targetaddress, 0x42);
|
||||
mm.getByte(targetaddress);
|
||||
|
||||
uint8_t tb[] = {0xab, 0xbb, 0xcc, 0xdd};
|
||||
mm.setBytes(targetaddress, 4, tb);
|
||||
*((uint32_t*)(tb)) = 0; // clear array.
|
||||
// read back bytes
|
||||
mm.getBytes(targetaddress, 4, tb);
|
||||
|
||||
// Test Listeners
|
||||
address_t address = 0xee;
|
||||
BPSingleListener bp(address);
|
||||
simulator.addListener(&bp);
|
||||
address_t address = m_elf.getSymbol("incfoo").getAddress();
|
||||
address &= ~1; // Cortex M3 Thumb Mode has the first bit set..
|
||||
m_log << "incfoo() @ 0x" << std::hex << address << std::endl;
|
||||
|
||||
address_t pfoo = m_elf.getSymbol("foo").getAddress();
|
||||
//BPSingleListener bp(address);
|
||||
BPRangeListener bp(address-32, address + 32);
|
||||
MemWriteListener l_foo( pfoo );
|
||||
simulator.addListener(&l_foo);
|
||||
reg = simulator.getCPU(0).getRegister(RI_R4);
|
||||
unsigned foo = 23;
|
||||
for(int i = 0; i < 15; i++){
|
||||
simulator.addListenerAndResume(&bp);
|
||||
if(i == 0) mm.setBytes(pfoo, 4, (void*)&foo);
|
||||
m_log << " Breakpoint hit! @ 0x" << std::hex << simulator.getCPU(0).getInstructionPointer() << std::endl;
|
||||
m_log << " Register R3: 0x" << hex << simulator.getCPU(0).getRegisterContent(reg) << endl;
|
||||
mm.getBytes(pfoo, 4, (void*)&foo);
|
||||
m_log << " foo @ 0x"<< std::hex << pfoo << " = " << foo << std::endl;
|
||||
}
|
||||
|
||||
/*
|
||||
BPRangeListener rbp(0xef, 0xff);
|
||||
simulator.addListener(&rbp);
|
||||
|
||||
@ -77,6 +74,19 @@ bool VEZSExperiment::run()
|
||||
// resume backend.
|
||||
// simulator.resume();
|
||||
|
||||
// Test Memory access
|
||||
address_t targetaddress = 0x12345678;
|
||||
MemoryManager& mm = simulator.getMemoryManager();
|
||||
mm.setByte(targetaddress, 0x42);
|
||||
mm.getByte(targetaddress);
|
||||
|
||||
uint8_t tb[] = {0xab, 0xbb, 0xcc, 0xdd};
|
||||
mm.setBytes(targetaddress, 4, tb);
|
||||
*((uint32_t*)(tb)) = 0; // clear array.
|
||||
// read back bytes
|
||||
mm.getBytes(targetaddress, 4, tb);
|
||||
|
||||
*/
|
||||
// Explicitly terminate, or the simulator will continue to run.
|
||||
simulator.terminate();
|
||||
}
|
||||
|
||||
@ -5,14 +5,18 @@
|
||||
#include "efw/JobClient.hpp"
|
||||
#include "util/Logger.hpp"
|
||||
|
||||
#include "util/Disassembler.hpp"
|
||||
#include "util/ElfReader.hpp"
|
||||
|
||||
class VEZSExperiment : public fail::ExperimentFlow {
|
||||
|
||||
fail::JobClient m_jc;
|
||||
fail::Logger m_log;
|
||||
fail::ElfReader m_elf;
|
||||
|
||||
public:
|
||||
VEZSExperiment() : m_log("VEZS-example", false) {};
|
||||
bool run();
|
||||
VEZSExperiment() : m_log("VEZS-example", false) {};
|
||||
bool run();
|
||||
};
|
||||
|
||||
#endif // __CHECKSUM_OOSTUBS_EXPERIMENT_HPP__
|
||||
|
||||
Reference in New Issue
Block a user