Add ElfImage to hold ELF image address and size.
(cherry picked from commit 578763dc6630156b163933720a85f8d34cbab652)
Change-Id: I76d03130eabb100869ea941c9e4fd92cc9244eeb
diff --git a/src/compiler_llvm/compilation_unit.h b/src/compiler_llvm/compilation_unit.h
index 4a23095..659bc64 100644
--- a/src/compiler_llvm/compilation_unit.h
+++ b/src/compiler_llvm/compilation_unit.h
@@ -18,6 +18,7 @@
#define ART_SRC_COMPILER_LLVM_COMPILATION_UNIT_H_
#include "constants.h"
+#include "elf_image.h"
#include "globals.h"
#include "logging.h"
@@ -76,12 +77,8 @@
bitcode_filename_ = filename;
}
- const byte* GetElfImage() const {
- return reinterpret_cast<const byte*>(&*elf_image_.begin());
- }
-
- size_t GetElfSize() const {
- return elf_image_.size();
+ ElfImage GetElfImage() const {
+ return ElfImage(elf_image_);
}
bool WriteBitcodeToFile();
diff --git a/src/compiler_llvm/compiler_llvm.cc b/src/compiler_llvm/compiler_llvm.cc
index 1d878c9..65d53b9 100644
--- a/src/compiler_llvm/compiler_llvm.cc
+++ b/src/compiler_llvm/compiler_llvm.cc
@@ -21,6 +21,7 @@
#include "compiled_method.h"
#include "compiler.h"
#include "dex_cache.h"
+#include "elf_image.h"
#include "elf_loader.h"
#include "ir_builder.h"
#include "jni_compiler.h"
@@ -205,9 +206,7 @@
compiler_lock_.AssertHeld();
DCHECK(cunit->IsMaterialized()) << cunit->GetElfIndex();
- if (!elf_loader_->LoadElfAt(cunit->GetElfIndex(),
- cunit->GetElfImage(),
- cunit->GetElfSize())) {
+ if (!elf_loader_->LoadElfAt(cunit->GetElfIndex(), cunit->GetElfImage())) {
LOG(ERROR) << "Failed to load ELF from compilation unit "
<< cunit->GetElfIndex();
}
diff --git a/src/compiler_llvm/compiler_llvm.h b/src/compiler_llvm/compiler_llvm.h
index 626c13d..f5a282a 100644
--- a/src/compiler_llvm/compiler_llvm.h
+++ b/src/compiler_llvm/compiler_llvm.h
@@ -19,6 +19,7 @@
#include "constants.h"
#include "dex_file.h"
+#include "elf_image.h"
#include "macros.h"
#include "object.h"
diff --git a/src/compiler_llvm/elf_loader.cc b/src/compiler_llvm/elf_loader.cc
index f309b82..ccb02ad 100644
--- a/src/compiler_llvm/elf_loader.cc
+++ b/src/compiler_llvm/elf_loader.cc
@@ -17,6 +17,7 @@
#include "elf_loader.h"
#include "compiled_method.h"
+#include "elf_image.h"
#include "logging.h"
#include "object.h"
#include "runtime_support_llvm.h"
@@ -36,7 +37,7 @@
}
-bool ElfLoader::LoadElfAt(size_t elf_idx, const byte* image, size_t size) {
+bool ElfLoader::LoadElfAt(size_t elf_idx, const ElfImage& elf_image) {
if (elf_idx < executables_.size() && executables_[elf_idx] != NULL) {
return false;
}
@@ -46,11 +47,13 @@
}
RSExecRef executable =
- rsloaderCreateExec(reinterpret_cast<const unsigned char*>(image),
- size, art_find_runtime_support_func, NULL);
+ rsloaderCreateExec(elf_image.begin(), elf_image.size(),
+ art_find_runtime_support_func, NULL);
if (executable == NULL) {
- LOG(WARNING) << "Failed to load ELF image: " << image << " size: " << size;
+ LOG(WARNING) << "Failed to load ELF"
+ << " image: " << elf_image.begin()
+ << " size: " << elf_image.size();
return false;
}
diff --git a/src/compiler_llvm/elf_loader.h b/src/compiler_llvm/elf_loader.h
index 5f7ab86..5c8063a 100644
--- a/src/compiler_llvm/elf_loader.h
+++ b/src/compiler_llvm/elf_loader.h
@@ -17,6 +17,7 @@
#ifndef ART_SRC_COMPILER_LLVM_ELF_LOADER_H_
#define ART_SRC_COMPILER_LLVM_ELF_LOADER_H_
+#include "elf_image.h"
#include "globals.h"
#include "object.h"
@@ -34,7 +35,7 @@
public:
~ElfLoader();
- bool LoadElfAt(size_t elf_idx, const byte* addr, size_t size);
+ bool LoadElfAt(size_t elf_idx, const ElfImage& elf_image);
const void* GetMethodCodeAddr(size_t elf_idx, const Method* method) const;