forked from Lephenixnoir/fxos
Lephenixnoir
d5c5fa6aeb
New features: * The syscall pass now resolves syscalls for the input target, provided that an OS is mapped on the ROM region. * Formalized the variations of print's arguments as a sequence (tree, to be precise) of /promotions/. * Added a short notion of Symbol and SymbolTable, and a loader for them. Data files of type "symbol" are read as such and provide name to syscalls or arbitrary addresses. Code changes: * The disassembly operation of the command-line interface is now finally in its own file with more room. * Encoded the tree structure of promotions as a sequence of (mainly tail-calling) inter-calling methods in the print pass.
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)));
|
|
}
|
|
}
|