From: Cocoa <r.xu.1@research.gla.ac.uk>
To: <libc-alpha@sourceware.org>
Subject: [PATCH] elf: clearer error message when ELF machine mismatches
Date: Sat, 15 Jan 2022 05:22:37 +0000 [thread overview]
Message-ID: <20220115052237.50170-1-r.xu.1@research.gla.ac.uk> (raw)
The misleading error message happens when trying to load 64-bit/32-bit
elf file but on a different machine(architecture). For example,
load an aarch64 elf file on a x86_64 host will give the error message
"No such file or directory" while the file exists.
Lastly, sorry that I am not a native English speaker, therefore,
please let me know if the error message needs to be phrased better, or
please suggest a proper one.
Many thanks.
>8
Set the error message to "ELF file machine does not match the host"
if elf machine does not match the host. The previous code jumps
to close_and_out and set errno to ENOENT, which results in a
misleading error message, "No such file or directory", while the
file acutally exists.
---
elf/dl-load.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/elf/dl-load.c b/elf/dl-load.c
index 12744caf..818a15e1 100644
--- a/elf/dl-load.c
+++ b/elf/dl-load.c
@@ -1729,7 +1729,10 @@ open_verify (const char *name, int fd,
goto lose;
}
if (! __glibc_likely (elf_machine_matches_host (ehdr)))
- goto close_and_out;
+ {
+ errstring = N_("ELF file machine does not match the host");
+ goto lose;
+ }
else if (__glibc_unlikely (ehdr->e_type != ET_DYN
&& ehdr->e_type != ET_EXEC))
{
--
2.30.1 (Apple Git-130)
reply other threads:[~2022-01-15 5:22 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220115052237.50170-1-r.xu.1@research.gla.ac.uk \
--to=r.xu.1@research.gla.ac.uk \
--cc=libc-alpha@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).