summaryrefslogtreecommitdiffstats
path: root/runtime/elf_file.cc
diff options
context:
space:
mode:
authorBrian Carlstrom <bdc@google.com>2013-11-06 18:25:35 -0800
committerBrian Carlstrom <bdc@google.com>2013-11-06 18:25:35 -0800
commitd0c09dc2177d132099a05af8537bdb9a8225af8c (patch)
treeca564f4b5774bb23b930c918c70009bd96f31dfb /runtime/elf_file.cc
parent1bd2ceb3a8c68ae6ea1f9627b588a7bc7a74487f (diff)
downloadart-d0c09dc2177d132099a05af8537bdb9a8225af8c.tar.gz
art-d0c09dc2177d132099a05af8537bdb9a8225af8c.tar.bz2
art-d0c09dc2177d132099a05af8537bdb9a8225af8c.zip
Add missing error message propagation to ElfFile::SetMap
Change-Id: I085e23cd4728e10a7efca3586270c6cffed9e8d4
Diffstat (limited to 'runtime/elf_file.cc')
-rw-r--r--runtime/elf_file.cc26
1 files changed, 15 insertions, 11 deletions
diff --git a/runtime/elf_file.cc b/runtime/elf_file.cc
index 15c95f2206..b3b24baf80 100644
--- a/runtime/elf_file.cc
+++ b/runtime/elf_file.cc
@@ -82,7 +82,8 @@ bool ElfFile::Setup(File* file, bool writable, bool program_header_only, std::st
// first just map ELF header to get program header size information
size_t elf_header_size = sizeof(llvm::ELF::Elf32_Ehdr);
if (!SetMap(MemMap::MapFile(elf_header_size, prot, flags, file_->Fd(), 0,
- file_->GetPath().c_str(), error_msg))) {
+ file_->GetPath().c_str(), error_msg),
+ error_msg)) {
return false;
}
// then remap to cover program header
@@ -94,14 +95,16 @@ bool ElfFile::Setup(File* file, bool writable, bool program_header_only, std::st
return false;
}
if (!SetMap(MemMap::MapFile(program_header_size, prot, flags, file_->Fd(), 0,
- file_->GetPath().c_str(), error_msg))) {
+ file_->GetPath().c_str(), error_msg),
+ error_msg)) {
*error_msg = StringPrintf("Failed to map ELF program headers: %s", error_msg->c_str());
return false;
}
} else {
// otherwise map entire file
if (!SetMap(MemMap::MapFile(file_->GetLength(), prot, flags, file_->Fd(), 0,
- file_->GetPath().c_str(), error_msg))) {
+ file_->GetPath().c_str(), error_msg),
+ error_msg)) {
*error_msg = StringPrintf("Failed to map ELF file: %s", error_msg->c_str());
return false;
}
@@ -173,9 +176,10 @@ ElfFile::~ElfFile() {
delete dynsym_symbol_table_;
}
-bool ElfFile::SetMap(MemMap* map) {
+bool ElfFile::SetMap(MemMap* map, std::string* error_msg) {
if (map == NULL) {
- // MemMap::Open should have already logged
+ // MemMap::Open should have already set an error.
+ DCHECK(!error_msg->empty());
return false;
}
map_.reset(map);
@@ -187,12 +191,12 @@ bool ElfFile::SetMap(MemMap* map) {
|| (llvm::ELF::ElfMagic[1] != header_->e_ident[llvm::ELF::EI_MAG1])
|| (llvm::ELF::ElfMagic[2] != header_->e_ident[llvm::ELF::EI_MAG2])
|| (llvm::ELF::ElfMagic[3] != header_->e_ident[llvm::ELF::EI_MAG3])) {
- LOG(WARNING) << "Failed to find ELF magic in " << file_->GetPath()
- << ": " << std::hex
- << static_cast<uint8_t>(header_->e_ident[llvm::ELF::EI_MAG0])
- << static_cast<uint8_t>(header_->e_ident[llvm::ELF::EI_MAG1])
- << static_cast<uint8_t>(header_->e_ident[llvm::ELF::EI_MAG2])
- << static_cast<uint8_t>(header_->e_ident[llvm::ELF::EI_MAG3]);
+ *error_msg = StringPrintf("Failed to find ELF magic in %s: %c%c%c%c",
+ file_->GetPath().c_str(),
+ header_->e_ident[llvm::ELF::EI_MAG0],
+ header_->e_ident[llvm::ELF::EI_MAG1],
+ header_->e_ident[llvm::ELF::EI_MAG2],
+ header_->e_ident[llvm::ELF::EI_MAG3]);
return false;
}