#include <unistd.h>
#include <ucontext.h>
+#include <llvm/Support/TargetRegistry.h>
#include <llvm/Support/TargetSelect.h>
+static const llvm::Target* target;
+static const llvm::MCDisassembler* disassembler;
+
static void handle_sigsegv(int signal, siginfo_t *info, void *_context)
{
(void)(signal); // it's unused, stfu gcc
llvm::InitializeAllTargetMCs();
llvm::InitializeAllDisassemblers();
+ std::string dontcare;
+ target = llvm::TargetRegistry::lookupTarget(
+ LLVM_HOST_TRIPLE,
+ dontcare);
+ if (!target) {
+ fprintf(stderr, "Cannot find target\n");
+ }
+
+ llvm::MCSubtargetInfo* sti = target->createMCSubtargetInfo("", "", "");
+ if (!sti) {
+ fprintf(stderr, "Couldn't create subtarget info\n");
+ }
+ disassembler = target->createMCDisassembler(*sti);
+ if (!disassembler) {
+ fprintf(stderr, "Couldn't create disassembler\n");
+ }
+
fprintf(stderr, "Set up signals\n");
sigset_t mask;
sigemptyset(&mask);