Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/libexec/ld.elf_so Improve the diagnostic messages for invali...
details: https://anonhg.NetBSD.org/src/rev/9906b862cdba
branches: trunk
changeset: 782061:9906b862cdba
user: dholland <dholland%NetBSD.org@localhost>
date: Sat Oct 13 21:13:07 2012 +0000
description:
Improve the diagnostic messages for invalid/non-ELF files. Proposed a
while back; I forget the context. Has been sitting in one of my trees
awaiting a test run since, apparently, August 2011.
diffstat:
libexec/ld.elf_so/map_object.c | 15 +++++++++------
1 files changed, 9 insertions(+), 6 deletions(-)
diffs (43 lines):
diff -r 0027667a5fdc -r 9906b862cdba libexec/ld.elf_so/map_object.c
--- a/libexec/ld.elf_so/map_object.c Sat Oct 13 21:03:09 2012 +0000
+++ b/libexec/ld.elf_so/map_object.c Sat Oct 13 21:13:07 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: map_object.c,v 1.44 2012/07/25 22:51:04 martin Exp $ */
+/* $NetBSD: map_object.c,v 1.45 2012/10/13 21:13:07 dholland Exp $ */
/*
* Copyright 1996 John D. Polstra.
@@ -34,7 +34,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: map_object.c,v 1.44 2012/07/25 22:51:04 martin Exp $");
+__RCSID("$NetBSD: map_object.c,v 1.45 2012/10/13 21:13:07 dholland Exp $");
#endif /* not lint */
#include <errno.h>
@@ -105,7 +105,7 @@
#endif
if (sb != NULL && sb->st_size < (off_t)sizeof (Elf_Ehdr)) {
- _rtld_error("%s: unrecognized file format1", path);
+ _rtld_error("%s: not ELF file (too short)", path);
return NULL;
}
@@ -125,9 +125,12 @@
goto bad;
}
/* Make sure the file is valid */
- if (memcmp(ELFMAG, ehdr->e_ident, SELFMAG) != 0 ||
- ehdr->e_ident[EI_CLASS] != ELFCLASS) {
- _rtld_error("%s: unrecognized file format2 [%x != %x]", path,
+ if (memcmp(ELFMAG, ehdr->e_ident, SELFMAG) != 0) {
+ _rtld_error("%s: not ELF file (magic number bad)", path);
+ goto bad;
+ }
+ if (ehdr->e_ident[EI_CLASS] != ELFCLASS) {
+ _rtld_error("%s: invalid ELF class %x; expected %x", path,
ehdr->e_ident[EI_CLASS], ELFCLASS);
goto bad;
}
Home |
Main Index |
Thread Index |
Old Index