2020-04-11 14:16:17 +03:00
|
|
|
#include <AK/LogStream.h>
|
|
|
|
#include <AK/MappedFile.h>
|
|
|
|
#include <LibX86/Disassembler.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
int main(int argc, char** argv)
|
|
|
|
{
|
|
|
|
if (argc == 1) {
|
|
|
|
fprintf(stderr, "usage: %s <binary>\n", argv[0]);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
MappedFile file(argv[1]);
|
|
|
|
|
|
|
|
X86::SimpleInstructionStream stream((const u8*)file.data(), file.size());
|
|
|
|
X86::Disassembler disassembler(stream);
|
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
auto offset = stream.offset();
|
|
|
|
auto insn = disassembler.next();
|
|
|
|
if (!insn.has_value())
|
|
|
|
break;
|
2020-04-11 14:23:59 +03:00
|
|
|
out() << String::format("%08x", offset) << " " << insn.value().to_string(offset);
|
2020-04-11 14:16:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|