summaryrefslogtreecommitdiff
path: root/compiler/elf_writer.cc
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/elf_writer.cc')
-rw-r--r--compiler/elf_writer.cc31
1 files changed, 22 insertions, 9 deletions
diff --git a/compiler/elf_writer.cc b/compiler/elf_writer.cc
index 55ee18e8d9..4219d97411 100644
--- a/compiler/elf_writer.cc
+++ b/compiler/elf_writer.cc
@@ -16,6 +16,7 @@
#include "elf_writer.h"
+#include "art_method-inl.h"
#include "base/unix_file/fd_file.h"
#include "class_linker.h"
#include "dex_file-inl.h"
@@ -23,15 +24,14 @@
#include "driver/compiler_driver.h"
#include "elf_file.h"
#include "invoke_type.h"
-#include "mirror/art_method-inl.h"
#include "mirror/object-inl.h"
#include "oat.h"
#include "scoped_thread_state_change.h"
namespace art {
-uint32_t ElfWriter::GetOatDataAddress(ElfFile* elf_file) {
- Elf32_Addr oatdata_address = elf_file->FindSymbolAddress(SHT_DYNSYM,
+uintptr_t ElfWriter::GetOatDataAddress(ElfFile* elf_file) {
+ uintptr_t oatdata_address = elf_file->FindSymbolAddress(SHT_DYNSYM,
"oatdata",
false);
CHECK_NE(0U, oatdata_address);
@@ -39,16 +39,29 @@ uint32_t ElfWriter::GetOatDataAddress(ElfFile* elf_file) {
}
void ElfWriter::GetOatElfInformation(File* file,
- size_t& oat_loaded_size,
- size_t& oat_data_offset) {
+ size_t* oat_loaded_size,
+ size_t* oat_data_offset) {
std::string error_msg;
std::unique_ptr<ElfFile> elf_file(ElfFile::Open(file, false, false, &error_msg));
CHECK(elf_file.get() != nullptr) << error_msg;
- oat_loaded_size = elf_file->GetLoadedSize();
- CHECK_NE(0U, oat_loaded_size);
- oat_data_offset = GetOatDataAddress(elf_file.get());
- CHECK_NE(0U, oat_data_offset);
+ bool success = elf_file->GetLoadedSize(oat_loaded_size, &error_msg);
+ CHECK(success) << error_msg;
+ CHECK_NE(0U, *oat_loaded_size);
+ *oat_data_offset = GetOatDataAddress(elf_file.get());
+ CHECK_NE(0U, *oat_data_offset);
+}
+
+bool ElfWriter::Fixup(File* file, uintptr_t oat_data_begin) {
+ std::string error_msg;
+ std::unique_ptr<ElfFile> elf_file(ElfFile::Open(file, true, false, &error_msg));
+ CHECK(elf_file.get() != nullptr) << error_msg;
+
+ // Lookup "oatdata" symbol address.
+ uintptr_t oatdata_address = ElfWriter::GetOatDataAddress(elf_file.get());
+ uintptr_t base_address = oat_data_begin - oatdata_address;
+
+ return elf_file->Fixup(base_address);
}
} // namespace art