tech-toolchain archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

bodgy error messages in ld.elf_so



Anyone object to the following patch? Someone hit one of these
messages the other day on chat, and it was clear they could use
improvement.

Index: map_object.c
===================================================================
RCS file: /cvsroot/src/libexec/ld.elf_so/map_object.c,v
retrieving revision 1.42
diff -u -p -r1.42 map_object.c
--- map_object.c        9 Mar 2011 23:10:07 -0000       1.42
+++ map_object.c        21 Aug 2011 20:04:56 -0000
@@ -105,7 +105,7 @@ _rtld_map_object(const char *path, int f
 #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 @@ _rtld_map_object(const char *path, int f
                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;
        }


-- 
David A. Holland
dholland%netbsd.org@localhost


Home | Main Index | Thread Index | Old Index