State clearly that an ELF file has the wrong architecture.
Before:
"libx.so" has unexpected e_machine: 40 (EM_ARM)
After:
"libx.so" is for EM_X86_64 (62) instead of EM_AARCH64 (183)
Bug: N/A
Test: `LD_PRELOAD=/system/lib64/libm-x86_64.so date` on arm64
Change-Id: I5bb40c435bd22b4e11fe802615925e10db7fb631
diff --git a/linker/linker_phdr.cpp b/linker/linker_phdr.cpp
index 0a7ccd8..8bf4c94 100644
--- a/linker/linker_phdr.cpp
+++ b/linker/linker_phdr.cpp
@@ -257,8 +257,10 @@
}
if (header_.e_machine != GetTargetElfMachine()) {
- DL_ERR("\"%s\" has unexpected e_machine: %d (%s)", name_.c_str(), header_.e_machine,
- EM_to_string(header_.e_machine));
+ DL_ERR("\"%s\" is for %s (%d) instead of %s (%d)",
+ name_.c_str(),
+ EM_to_string(header_.e_machine), header_.e_machine,
+ EM_to_string(GetTargetElfMachine()), GetTargetElfMachine());
return false;
}