aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/MC/MCDisassembler/Disassembler.cpp
diff options
context:
space:
mode:
authorKevin Enderby <enderby@apple.com>2012-02-17 19:18:29 +0000
committerKevin Enderby <enderby@apple.com>2012-02-17 19:18:29 +0000
commit86f94ce50952b08dd669b63f56f1a2e83f274506 (patch)
tree5b96cfd70ac561f4b64ee406fc11ec7b60601b63 /llvm/lib/MC/MCDisassembler/Disassembler.cpp
parent96732a438dc8de4cf619402d82e63e725575b47e (diff)
downloadllvm-86f94ce50952b08dd669b63f56f1a2e83f274506.zip
llvm-86f94ce50952b08dd669b63f56f1a2e83f274506.tar.gz
llvm-86f94ce50952b08dd669b63f56f1a2e83f274506.tar.bz2
Put back the initializing the targets in the disassembler API with a comment as
to why this is needed. This broke the darwin's otool(1) program. This change was made in r144385. llvm-svn: 150832
Diffstat (limited to 'llvm/lib/MC/MCDisassembler/Disassembler.cpp')
-rw-r--r--llvm/lib/MC/MCDisassembler/Disassembler.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/llvm/lib/MC/MCDisassembler/Disassembler.cpp b/llvm/lib/MC/MCDisassembler/Disassembler.cpp
index dee576e..c6c67c5 100644
--- a/llvm/lib/MC/MCDisassembler/Disassembler.cpp
+++ b/llvm/lib/MC/MCDisassembler/Disassembler.cpp
@@ -18,6 +18,7 @@
#include "llvm/MC/MCRegisterInfo.h"
#include "llvm/Support/MemoryObject.h"
#include "llvm/Support/TargetRegistry.h"
+#include "llvm/Support/TargetSelect.h"
#include "llvm/Support/ErrorHandling.h"
namespace llvm {
@@ -35,6 +36,18 @@ using namespace llvm;
LLVMDisasmContextRef LLVMCreateDisasm(const char *TripleName, void *DisInfo,
int TagType, LLVMOpInfoCallback GetOpInfo,
LLVMSymbolLookupCallback SymbolLookUp) {
+ // Initialize targets and assembly printers/parsers.
+ // FIXME: Clients are responsible for initializing the targets. And this
+ // would be done by calling routines in "llvm-c/Target.h" which are static
+ // line functions. But the current use of LLVMCreateDisasm() is to dynamically
+ // load libLTO with ldopen() and then lookup the symbols using dlsym().
+ // And since these initialize routines are static that does not work which
+ // is why the call to them in this 'C' library API was added back.
+ llvm::InitializeAllTargetInfos();
+ llvm::InitializeAllTargetMCs();
+ llvm::InitializeAllAsmParsers();
+ llvm::InitializeAllDisassemblers();
+
// Get the target.
std::string Error;
const Target *TheTarget = TargetRegistry::lookupTarget(TripleName, Error);