forked from Lephenixnoir/fxos
77 lines
2.9 KiB
C++
77 lines
2.9 KiB
C++
static std::string help_string = colors(R"(
|
|
usage: <R>fxos<> [<R>library<>|<R>info<>|<R>disasm<>|<R>analyze<>]
|
|
|
|
fxos is a reverse-engineering tool that disassembles and analyzes SuperH
|
|
programs and OS dumps for CASIO calculators of the fx-9860G and fx-CG 50
|
|
families, using an editable database of platform, syscall, and OS knowledge.
|
|
|
|
General options:
|
|
<R>-3<>, <R>--sh3<> Assume SH3 OS and platform (default: SH4)
|
|
<R>-4<>, <R>--sh4<> Assume SH4 OS and platform (default: SH4)
|
|
<R>-v<>, <R>--verbose<> Print logs about what's happening
|
|
|
|
<R>fxos library<> [<R>-t<>] [<R>-a<>]
|
|
Prints out the contents of the library. If an option is set, the results are
|
|
printed in a simple easily-parsable form without header.
|
|
|
|
Selectors:
|
|
<R>-t<>, <R>--targets<> Print all targets
|
|
<R>-a<>, <R>--asm<> Print all assembler instruction sets
|
|
|
|
<R>fxos info<> <<P>TARGET<>>
|
|
Print adentification and basic information about an OS image: version,
|
|
platform, date, checksums...
|
|
|
|
Target specification:
|
|
<<P>TARGET-NAME<>> Named target in library (eg. "fx@3.10")
|
|
<R>-f<> <<P>FILE<>> Arbitrary file which is loaded as ROM
|
|
|
|
<R>fxos disasm<> <<P>TARGET<>> <<P>LOCATION<>> [options...]
|
|
Disassemble and annotate code with relative address targets, syscalls,
|
|
control flow, propagated constants and hints about memory structure.
|
|
|
|
Location specifiers:
|
|
<<P>ADDRESS<>> Start disassembling at this address (hexa)
|
|
<<P>ADDRESS<>>:<<P>LEN<>> Disassemble exactly the specified region. <P>len<> is an
|
|
hexadecimal number optionally followed by k, M, or G.
|
|
%<<P>SYSCALL-ID<>> Start disassembling at this syscall's address (hexa)
|
|
<<P>SYMBOL<>> Disassemble this library symbol (typically syscall name).
|
|
A name which is valid hexadecimal is treated as <P>ADDRESS<>.
|
|
Disassembly options:
|
|
<R>-p<> <<P>PASSES<>> Execute the specified comma-separated list of passes
|
|
Available passes:
|
|
cfg Build the control flow graph (always required)
|
|
pcrel Resolve PC-relative references as their target address
|
|
cstprop Propagate constants by abstract interpretation
|
|
syscall Annotate code with reverse syscalls
|
|
|
|
The default sequence of passes is <W>cfg,pcrel,cstprop,syscall<>. When
|
|
disassembling a function (ie. no size specified on the command-line), the cfg
|
|
pass is always executed to obtain the code of the function.
|
|
)"+1);
|
|
|
|
int main_disassembly(int argc, char **argv)
|
|
{
|
|
std::vector<std::string> passes {
|
|
"cfg", "pcrel", "constprop", "syscall", "print"
|
|
};
|
|
if(passes.back() != "print") passes.push_back("print");
|
|
|
|
try
|
|
{
|
|
int rc = disassembly(lib, space, ref, passes);
|
|
if(log_getminlevel() <= LEVEL_LOG) malloc_stats();
|
|
return rc;
|
|
}
|
|
catch(LangError &e)
|
|
{
|
|
log(ERR "%08x: %s", e.addr(), e.what());
|
|
return 1;
|
|
}
|
|
catch(AddressError &e)
|
|
{
|
|
log(ERR "%08x[%d]: %s", e.addr(), e.size(), e.what());
|
|
return 1;
|
|
}
|
|
}
|