diff --git a/sys/kern/link_elf.c b/sys/kern/link_elf.c index bdaa63633920..2664ba988946 100644 --- a/sys/kern/link_elf.c +++ b/sys/kern/link_elf.c @@ -232,9 +232,12 @@ Elf_Addr link_elf_get_gp(linker_file_t); extern struct _dynamic _DYNAMIC; static void -link_elf_error(const char *s) +link_elf_error(const char *filename, const char *s) { - printf("kldload: %s\n", s); + if (filename == NULL) + printf("kldload: %s\n", s); + else + printf("kldload: %s: %s\n", filename, s); } /* @@ -624,23 +627,23 @@ link_elf_load_file(linker_class_t cls, const char* filename, if (hdr->e_ident[EI_CLASS] != ELF_TARG_CLASS || hdr->e_ident[EI_DATA] != ELF_TARG_DATA) { - link_elf_error("Unsupported file layout"); + link_elf_error(filename, "Unsupported file layout"); error = ENOEXEC; goto out; } if (hdr->e_ident[EI_VERSION] != EV_CURRENT || hdr->e_version != EV_CURRENT) { - link_elf_error("Unsupported file version"); + link_elf_error(filename, "Unsupported file version"); error = ENOEXEC; goto out; } if (hdr->e_type != ET_EXEC && hdr->e_type != ET_DYN) { - link_elf_error("Unsupported file type"); + link_elf_error(filename, "Unsupported file type"); error = ENOEXEC; goto out; } if (hdr->e_machine != ELF_TARG_MACH) { - link_elf_error("Unsupported machine"); + link_elf_error(filename, "Unsupported machine"); error = ENOEXEC; goto out; } @@ -653,7 +656,7 @@ link_elf_load_file(linker_class_t cls, const char* filename, if (!((hdr->e_phentsize == sizeof(Elf_Phdr)) && (hdr->e_phoff + hdr->e_phnum*sizeof(Elf_Phdr) <= PAGE_SIZE) && (hdr->e_phoff + hdr->e_phnum*sizeof(Elf_Phdr) <= nbytes))) - link_elf_error("Unreadable program headers"); + link_elf_error(filename, "Unreadable program headers"); /* * Scan the program header entries, and save key information. @@ -671,7 +674,7 @@ link_elf_load_file(linker_class_t cls, const char* filename, case PT_LOAD: if (nsegs == MAXSEGS) { - link_elf_error("Too many sections"); + link_elf_error(filename, "Too many sections"); error = ENOEXEC; goto out; } @@ -691,7 +694,7 @@ link_elf_load_file(linker_class_t cls, const char* filename, break; case PT_INTERP: - link_elf_error("Unsupported file type"); + link_elf_error(filename, "Unsupported file type"); error = ENOEXEC; goto out; } @@ -699,12 +702,12 @@ link_elf_load_file(linker_class_t cls, const char* filename, ++phdr; } if (phdyn == NULL) { - link_elf_error("Object is not dynamically-linked"); + link_elf_error(filename, "Object is not dynamically-linked"); error = ENOEXEC; goto out; } if (nsegs == 0) { - link_elf_error("No sections"); + link_elf_error(filename, "No sections"); error = ENOEXEC; goto out; } diff --git a/sys/kern/link_elf_obj.c b/sys/kern/link_elf_obj.c index f8ef7f30e77c..e2ea863c01c3 100644 --- a/sys/kern/link_elf_obj.c +++ b/sys/kern/link_elf_obj.c @@ -170,9 +170,12 @@ static struct linker_class link_elf_class = { static int relocate_file(elf_file_t ef); static void -link_elf_error(const char *s) +link_elf_error(const char *filename, const char *s) { - printf("kldload: %s\n", s); + if (filename == NULL) + printf("kldload: %s\n", s); + else + printf("kldload: %s: %s\n", filename, s); } static void @@ -460,23 +463,23 @@ link_elf_load_file(linker_class_t cls, const char *filename, if (hdr->e_ident[EI_CLASS] != ELF_TARG_CLASS || hdr->e_ident[EI_DATA] != ELF_TARG_DATA) { - link_elf_error("Unsupported file layout"); + link_elf_error(filename, "Unsupported file layout"); error = ENOEXEC; goto out; } if (hdr->e_ident[EI_VERSION] != EV_CURRENT || hdr->e_version != EV_CURRENT) { - link_elf_error("Unsupported file version"); + link_elf_error(filename, "Unsupported file version"); error = ENOEXEC; goto out; } if (hdr->e_type != ET_REL) { - link_elf_error("Unsupported file type"); + link_elf_error(filename, "Unsupported file type"); error = ENOEXEC; goto out; } if (hdr->e_machine != ELF_TARG_MACH) { - link_elf_error("Unsupported machine"); + link_elf_error(filename, "Unsupported machine"); error = ENOEXEC; goto out; } @@ -540,19 +543,19 @@ link_elf_load_file(linker_class_t cls, const char *filename, } } if (ef->nprogtab == 0) { - link_elf_error("file has no contents"); + link_elf_error(filename, "file has no contents"); error = ENOEXEC; goto out; } if (nsym != 1) { /* Only allow one symbol table for now */ - link_elf_error("file has no valid symbol table"); + link_elf_error(filename, "file has no valid symbol table"); error = ENOEXEC; goto out; } if (symstrindex < 0 || symstrindex > hdr->e_shnum || shdr[symstrindex].sh_type != SHT_STRTAB) { - link_elf_error("file has invalid symbol strings"); + link_elf_error(filename, "file has invalid symbol strings"); error = ENOEXEC; goto out; }