Add ELF loader to load the executables.

(cherry picked from commit 8c9ca414a7ed05c3530973c63496e477e9ca5eb7)

Conflicts:

	src/compiler.cc

Change-Id: I950749625d5b266990c617e2d8cea688fbdc11fb
diff --git a/src/compiler.cc b/src/compiler.cc
index 0431d74..c5da125 100644
--- a/src/compiler.cc
+++ b/src/compiler.cc
@@ -322,7 +322,13 @@
       compiler_(NULL),
       compiler_context_(NULL),
       jni_compiler_(NULL),
-      create_invoke_stub_(NULL) {
+      create_invoke_stub_(NULL)
+#if defined(ART_USE_LLVM_COMPILER)
+    , compiler_enable_auto_elf_loading_(NULL),
+      compiler_get_method_code_addr_(NULL),
+      compiler_get_method_invoke_stub_addr_(NULL)
+#endif
+{
   std::string compiler_so_name(MakeCompilerSoName(instruction_set_));
   compiler_library_ = dlopen(compiler_so_name.c_str(), RTLD_LAZY);
   if (compiler_library_ == NULL) {
@@ -346,6 +352,15 @@
   jni_compiler_ = FindFunction<JniCompilerFn>(compiler_so_name, compiler_library_, "ArtJniCompileMethod");
   create_invoke_stub_ = FindFunction<CreateInvokeStubFn>(compiler_so_name, compiler_library_, "ArtCreateInvokeStub");
 
+#if defined(ART_USE_LLVM_COMPILER)
+  compiler_enable_auto_elf_loading_ = FindFunction<CompilerEnableAutoElfLoadingFn>(
+      compiler_so_name, compiler_library_, "compilerLLVMEnableAutoElfLoading");
+  compiler_get_method_code_addr_ = FindFunction<CompilerGetMethodCodeAddrFn>(
+      compiler_so_name, compiler_library_, "compilerLLVMGetMethodCodeAddr");
+  compiler_get_method_invoke_stub_addr_ = FindFunction<CompilerGetMethodInvokeStubAddrFn>(
+      compiler_so_name, compiler_library_, "compilerLLVMGetMethodInvokeStubAddr");
+#endif
+
   CHECK(!Runtime::Current()->IsStarted());
   if (!image_) {
     CHECK(image_classes_ == NULL);
@@ -1429,6 +1444,20 @@
 
   set_bitcode_file_name(*this, filename);
 }
+
+void Compiler::EnableAutoElfLoading() {
+  compiler_enable_auto_elf_loading_(*this);
+}
+
+const void* Compiler::GetMethodCodeAddr(const CompiledMethod* cm,
+                                        const Method* method) const {
+  return compiler_get_method_code_addr_(*this, cm, method);
+}
+
+const Method::InvokeStub* Compiler::GetMethodInvokeStubAddr(const CompiledInvokeStub* cm,
+                                                            const Method* method) const {
+  return compiler_get_method_invoke_stub_addr_(*this, cm, method);
+}
 #endif
 
 }  // namespace art