Merge "linker: improve "bad ELF magic" error."

This commit is contained in:
Treehugger Robot 2018-06-28 01:03:11 +00:00 committed by Gerrit Code Review
commit 363eac0bab
2 changed files with 3 additions and 2 deletions

View file

@ -213,7 +213,8 @@ static const char* EM_to_string(int em) {
bool ElfReader::VerifyElfHeader() {
if (memcmp(header_.e_ident, ELFMAG, SELFMAG) != 0) {
DL_ERR("\"%s\" has bad ELF magic", name_.c_str());
DL_ERR("\"%s\" has bad ELF magic: %02x%02x%02x%02x", name_.c_str(),
header_.e_ident[0], header_.e_ident[1], header_.e_ident[2], header_.e_ident[3]);
return false;
}

View file

@ -173,7 +173,7 @@ TEST_F(DlExtTest, ExtInfoUseFdWithInvalidOffset) {
extinfo.library_fd_offset = 0;
handle_ = android_dlopen_ext("libname_ignored", RTLD_NOW, &extinfo);
ASSERT_TRUE(handle_ == nullptr);
ASSERT_EQ("dlopen failed: \"" + lib_path + "\" has bad ELF magic", dlerror());
ASSERT_EQ("dlopen failed: \"" + lib_path + "\" has bad ELF magic: 504b0304", dlerror());
// Check if dlsym works after unsuccessful dlopen().
// Supply non-exiting one to make linker visit every soinfo.