Skip to content

Commit

Permalink
Better target lookup in llvm backend (BinaryAnalysisPlatform#530)
Browse files Browse the repository at this point in the history
* better target lookup in LLVM backend

The new lookup stategy follows closely llvm-mc implementation. It is
able to find all existing architectures, and systemz, that we weren't
able to use before.

* a more intensive target lookup in llvm backend

This patch adds a support for systemz architecture. For some reason,
if passed without name, a target is found, but RegInfo structure is
not. On the other hand, all other architectures, except, mips, can't be
found at all if an architecture is passed explicitly. So, we try both,
first search using official method with both arch and triple specified.
If it fails, then specify only triple.

* updated testsuite
  • Loading branch information
ivg authored Jul 28, 2016
1 parent add6cf1 commit 5787ed9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 9 additions & 3 deletions plugins/llvm/llvm_disasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class MemoryObject : public llvm::MemoryObject {

class llvm_disassembler;

static void output_error(const char *triple, const char *cpu,
static void output_error(std::string triple, const char *cpu,
std::string error, std::string tail="") {
std::cerr
<< "llvm_disasm: failed to create llvm_disassmbler for:\n"
Expand Down Expand Up @@ -115,12 +115,18 @@ class llvm_disassembler : public disassembler_interface {

public:
static result<llvm_disassembler>
create(const char *triple, const char *cpu, int debug_level) {
create(const char *name, const char *cpu, int debug_level) {
std::string error;
llvm::Triple t(llvm::Triple::normalize(name));
std::string triple = t.getTriple();

// returned value is not allocted
const llvm::Target *target =
llvm::TargetRegistry::lookupTarget(triple, error);
llvm::TargetRegistry::lookupTarget(name,t,error);;

if (!target) {
target = llvm::TargetRegistry::lookupTarget("", t, error);
}

if (!target) {
if (debug_level > 0)
Expand Down
2 changes: 1 addition & 1 deletion testsuite
Submodule testsuite updated 1 files
+1 −0 mc.tests/mov.exp

0 comments on commit 5787ed9

Please sign in to comment.