* [PATCH] elf: clearer error message when ELF machine mismatches
@ 2022-01-15 5:22 Cocoa
0 siblings, 0 replies; only message in thread
From: Cocoa @ 2022-01-15 5:22 UTC (permalink / raw)
To: libc-alpha
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)
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-01-15 5:22 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-15 5:22 [PATCH] elf: clearer error message when ELF machine mismatches Cocoa
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).