cl::desc("Target a specific cpu type (-mcpu=help for details)"),
cl::value_desc("cpu-name"), cl::init(""));
+// This is useful for variable-length instruction sets.
+static cl::opt<unsigned> InsnLimit(
+ "insn-limit",
+ cl::desc("Limit the number of instructions to process (0 for no limit)"),
+ cl::value_desc("count"), cl::init(0));
+
static cl::list<std::string>
MAttrs("mattr", cl::CommaSeparated,
cl::desc("Target specific attributes (-mattr=help for details)"),
cl::desc("Options to pass to the fuzzer"), cl::ZeroOrMore,
cl::PositionalEatsArgs);
-void DisassembleOneInput(const uint8_t *Data, size_t Size) {
+int DisassembleOneInput(const uint8_t *Data, size_t Size) {
char AssemblyText[AssemblyTextBufSize];
std::vector<uint8_t> DataCopy(Data, Data + Size);
assert(Ctx);
uint8_t *p = DataCopy.data();
unsigned Consumed;
+ unsigned InstructionsProcessed = 0;
do {
Consumed = LLVMDisasmInstruction(Ctx, p, Size, 0, AssemblyText,
AssemblyTextBufSize);
Size -= Consumed;
p += Consumed;
+
+ InstructionsProcessed ++;
+ if (InsnLimit != 0 && InstructionsProcessed < InsnLimit)
+ break;
} while (Consumed != 0);
LLVMDisasmDispose(Ctx);
+ return 0;
}
int main(int argc, char **argv) {
FeaturesStr = Features.getString();
}
- // Insert the program name into the FuzzerArgv.
- FuzzerArgv.insert(FuzzerArgv.begin(), argv[0]);
-
if (Action == AC_Assemble)
errs() << "error: -assemble is not implemented\n";
else if (Action == AC_Disassemble)
- return fuzzer::FuzzerDriver(FuzzerArgv, DisassembleOneInput);
+ return fuzzer::FuzzerDriver(argc, argv, DisassembleOneInput);
llvm_unreachable("Unknown action");
return 1;