Remove ELF filename argument.

We are embedding the ELF image in the Oat file.  We don't
need ELF filename anymore.

(cherry picked from commit b245ccacf447b014838535a7d8a58365642f0c3d)

Change-Id: I235429222401100c09381ba44a3978f38d5b499c
diff --git a/src/common_test.h b/src/common_test.h
index a79b619..e05a6d5 100644
--- a/src/common_test.h
+++ b/src/common_test.h
@@ -369,7 +369,6 @@
     compiler_.reset(new Compiler(instruction_set, true, 2, false, new std::set<std::string>,
                                  true, true));
 #if defined(ART_USE_LLVM_COMPILER)
-    compiler_->SetElfFileName("gtest");
     compiler_->EnableAutoElfLoading();
 #endif
 
diff --git a/src/compiler.cc b/src/compiler.cc
index ba8853a..3388f72 100644
--- a/src/compiler.cc
+++ b/src/compiler.cc
@@ -1423,17 +1423,6 @@
 }
 
 #if defined(ART_USE_LLVM_COMPILER)
-void Compiler::SetElfFileName(std::string const& filename) {
-  typedef void (*SetElfFileNameFn)(Compiler&, std::string const&);
-
-  SetElfFileNameFn set_elf_file_name =
-    FindFunction<SetElfFileNameFn>(MakeCompilerSoName(instruction_set_),
-                                   compiler_library_,
-                                   "compilerLLVMSetElfFileName");
-
-  set_elf_file_name(*this, filename);
-}
-
 void Compiler::SetBitcodeFileName(std::string const& filename) {
   typedef void (*SetBitcodeFileNameFn)(Compiler&, std::string const&);
 
diff --git a/src/compiler.h b/src/compiler.h
index 74af408..5f4e5ca 100644
--- a/src/compiler.h
+++ b/src/compiler.h
@@ -137,7 +137,6 @@
                       size_t literal_offset);
 
 #if defined(ART_USE_LLVM_COMPILER)
-  void SetElfFileName(std::string const& filename);
   void SetBitcodeFileName(std::string const& filename);
 
   void EnableAutoElfLoading();
diff --git a/src/compiler_llvm/compilation_unit.cc b/src/compiler_llvm/compilation_unit.cc
index b73e997..3b4defd 100644
--- a/src/compiler_llvm/compilation_unit.cc
+++ b/src/compiler_llvm/compilation_unit.cc
@@ -194,16 +194,7 @@
     pm.run(*module_);
   }
 
-  // Write ELF image to file
-  // TODO: Remove this when we can embed the ELF image in the Oat file.
-  // We are keeping these code to run the unit test.
-  llvm::OwningPtr<llvm::tool_output_file> out_file(
-    new llvm::tool_output_file(elf_filename_.c_str(), errmsg,
-                               llvm::raw_fd_ostream::F_Binary));
-  out_file->os().write(elf_image_.data(), elf_image_.size());
-  out_file->keep();
-
-  LOG(INFO) << "ELF: " << elf_filename_ << " (done)";
+  LOG(INFO) << "Compilation Unit: " << elf_idx_ << " (done)";
 
   // Free the resources
   context_.reset(NULL);
diff --git a/src/compiler_llvm/compilation_unit.h b/src/compiler_llvm/compilation_unit.h
index 659bc64..57d559b 100644
--- a/src/compiler_llvm/compilation_unit.h
+++ b/src/compiler_llvm/compilation_unit.h
@@ -61,18 +61,10 @@
     return irb_.get();
   }
 
-  std::string const& GetElfFileName() const {
-    return elf_filename_;
-  }
-
   std::string const& GetBitcodeFileName() const {
     return bitcode_filename_;
   }
 
-  void SetElfFileName(std::string const& filename) {
-    elf_filename_ = filename;
-  }
-
   void SetBitcodeFileName(std::string const& filename) {
     bitcode_filename_ = filename;
   }
@@ -106,7 +98,6 @@
   llvm::Module* module_;
 
   std::string elf_image_;
-  std::string elf_filename_;
   std::string bitcode_filename_;
 
   size_t mem_usage_;
diff --git a/src/compiler_llvm/compiler_llvm.cc b/src/compiler_llvm/compiler_llvm.cc
index e02c913..a646b6f 100644
--- a/src/compiler_llvm/compiler_llvm.cc
+++ b/src/compiler_llvm/compiler_llvm.cc
@@ -125,10 +125,7 @@
 
   curr_cunit_ = new CompilationUnit(insn_set_, cunit_idx);
 
-  // Setup output filename
-  curr_cunit_->SetElfFileName(
-    StringPrintf("%s-%zu", elf_filename_.c_str(), cunit_idx));
-
+  // Setup bitcode output filename
   if (IsBitcodeFileNameAvailable()) {
     curr_cunit_->SetBitcodeFileName(
       StringPrintf("%s-%zu", bitcode_filename_.c_str(), cunit_idx));
@@ -337,11 +334,6 @@
   return ContextOf(compiler)->CreateInvokeStub(is_static, shorty);
 }
 
-extern "C" void compilerLLVMSetElfFileName(art::Compiler& compiler,
-                                           std::string const& filename) {
-  ContextOf(compiler)->SetElfFileName(filename);
-}
-
 extern "C" void compilerLLVMSetBitcodeFileName(art::Compiler& compiler,
                                                std::string const& filename) {
   ContextOf(compiler)->SetBitcodeFileName(filename);
diff --git a/src/compiler_llvm/compiler_llvm.h b/src/compiler_llvm/compiler_llvm.h
index 90537ff..2c37ac0 100644
--- a/src/compiler_llvm/compiler_llvm.h
+++ b/src/compiler_llvm/compiler_llvm.h
@@ -83,10 +83,6 @@
     return cunits_[i];
   }
 
-  void SetElfFileName(std::string const& filename) {
-    elf_filename_ = filename;
-  }
-
   void SetBitcodeFileName(std::string const& filename) {
     bitcode_filename_ = filename;
   }
@@ -135,8 +131,6 @@
 
   std::vector<CompilationUnit*> cunits_;
 
-  std::string elf_filename_;
-
   std::string bitcode_filename_;
 
   UniquePtr<ElfLoader> elf_loader_;
diff --git a/src/dex2oat.cc b/src/dex2oat.cc
index f2696e3..e18a628 100644
--- a/src/dex2oat.cc
+++ b/src/dex2oat.cc
@@ -79,9 +79,6 @@
   UsageError("      Example: --oat-location=/data/art-cache/system@app@Calculator.apk.oat");
   UsageError("");
 #if defined(ART_USE_LLVM_COMPILER)
-  UsageError("  --elf-file=<file.elf>: specifies the required elf filename.");
-  UsageError("      Example: --elf-file=/system/framework/boot.elf");
-  UsageError("");
   UsageError("  --bitcode=<file.bc>: specifies the optional bitcode filename.");
   UsageError("      Example: --bitcode=/system/framework/boot.bc");
   UsageError("");
@@ -203,8 +200,7 @@
                                 const std::vector<const DexFile*>& dex_files,
                                 File* oat_file,
 #if defined(ART_USE_LLVM_COMPILER)
-                                std::string const& elf_filename,
-                                std::string const& bitcode_filename,
+                                const std::string& bitcode_filename,
 #endif
                                 bool image,
                                 const std::set<std::string>* image_classes,
@@ -236,7 +232,6 @@
                                               dump_timings));
 
 #if defined(ART_USE_LLVM_COMPILER)
-    compiler->SetElfFileName(elf_filename);
     compiler->SetBitcodeFileName(bitcode_filename);
 #endif
 
@@ -465,7 +460,6 @@
   std::string oat_location;
   int oat_fd = -1;
 #if defined(ART_USE_LLVM_COMPILER)
-  std::string elf_filename;
   std::string bitcode_filename;
 #endif
   const char* image_classes_filename = NULL;
@@ -514,8 +508,6 @@
     } else if (option.starts_with("--oat-location=")) {
       oat_location = option.substr(strlen("--oat-location=")).data();
 #if defined(ART_USE_LLVM_COMPILER)
-    } else if (option.starts_with("--elf-file=")) {
-      elf_filename = option.substr(strlen("--elf-file=")).data();
     } else if (option.starts_with("--bitcode=")) {
       bitcode_filename = option.substr(strlen("--bitcode=")).data();
 #endif
@@ -650,21 +642,6 @@
 
   LOG(INFO) << "dex2oat: " << oat_location;
 
-#if defined(ART_USE_LLVM_COMPILER)
-  if (elf_filename.empty()) {
-    if (oat_filename.empty()) {
-      LOG(FATAL) << "Both --oat-file and --elf-file are not specified";
-    }
-
-    StringPiece elf_filename_sp(oat_filename);
-    if (elf_filename_sp.ends_with(".oat")) {
-      elf_filename_sp.remove_suffix(strlen(".oat"));
-    }
-
-    elf_filename = elf_filename_sp.ToString() + ".elf";
-  }
-#endif
-
   Runtime::Options options;
   options.push_back(std::make_pair("compiler", reinterpret_cast<void*>(NULL)));
   std::vector<const DexFile*> boot_class_path;
@@ -720,7 +697,6 @@
                                                             dex_files,
                                                             oat_file.get(),
 #if defined(ART_USE_LLVM_COMPILER)
-                                                            elf_filename,
                                                             bitcode_filename,
 #endif
                                                             image,
@@ -733,9 +709,6 @@
     return EXIT_FAILURE;
   }
 
-#if defined(ART_USE_LLVM_COMPILER)
-  LOG(INFO) << "oat=" << oat_location << " elf=" << elf_filename;
-#endif
   if (!image) {
     LOG(INFO) << "Oat file written successfully: " << oat_location;
     return EXIT_SUCCESS;