63 lines
1.4 KiB
C++
63 lines
1.4 KiB
C++
#include "fxos-cli.h"
|
|
#include <fxos/disassembly.h>
|
|
#include <fxos/memory.h>
|
|
#include <fxos/target.h>
|
|
#include <fxos/util.h>
|
|
#include <fxos/log.h>
|
|
#include <fxos/os.h>
|
|
|
|
#include <fxos/disasm-passes/cfg.h>
|
|
#include <fxos/disasm-passes/pcrel.h>
|
|
#include <fxos/disasm-passes/syscall.h>
|
|
#include <fxos/disasm-passes/print.h>
|
|
|
|
using namespace FxOS;
|
|
using namespace FxOS::Log;
|
|
|
|
void disassembly(Library &library, Target &target, uint32_t ref,
|
|
std::vector<std::string> passes)
|
|
{
|
|
Disassembly disasm(target);
|
|
|
|
/* Observe the target only if it has an OS mapped */
|
|
std::unique_ptr<OS> os;
|
|
if(target.covers(MemoryRegion::ROM))
|
|
os = std::make_unique<OS>(target);
|
|
|
|
for(auto pass: passes)
|
|
{
|
|
auto start = timer_start();
|
|
log(LOG "Running pass %s...\\", pass);
|
|
|
|
if(pass == "cfg")
|
|
{
|
|
CfgPass p(disasm);
|
|
p.run(ref);
|
|
}
|
|
else if(pass == "pcrel")
|
|
{
|
|
PcrelPass p(disasm);
|
|
p.run(ref);
|
|
}
|
|
else if(pass == "syscall")
|
|
{
|
|
SyscallPass p(disasm, os.get());
|
|
p.run(ref);
|
|
}
|
|
else if(pass == "print")
|
|
{
|
|
PrintPass p(disasm, library.sym_tables());
|
|
|
|
p.promote_pcjump_loc = PrintPass::Promote;
|
|
p.promote_pcrel_loc = PrintPass::Promote;
|
|
p.promote_pcrel_value = PrintPass::Promote;
|
|
p.promote_syscall = PrintPass::Promote;
|
|
p.promote_syscallname = PrintPass::Append;
|
|
p.promote_symbol = PrintPass::Append;
|
|
|
|
p.run();
|
|
}
|
|
log(LOG "%s", timer_format(timer_end(start)));
|
|
}
|
|
}
|