From d16cface55985257621a977d2f711de1a8202422 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Mon, 17 Sep 2018 15:50:09 -0700 Subject: [PATCH] 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 --- linker/linker_phdr.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/linker/linker_phdr.cpp b/linker/linker_phdr.cpp index 0a7ccd800..8bf4c94c0 100644 --- a/linker/linker_phdr.cpp +++ b/linker/linker_phdr.cpp @@ -257,8 +257,10 @@ bool ElfReader::VerifyElfHeader() { } 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; }