summaryrefslogtreecommitdiffstats
path: root/sys/kern/link_elf_obj.c
diff options
context:
space:
mode:
authoredwin <edwin@FreeBSD.org>2008-07-08 23:51:38 +0000
committeredwin <edwin@FreeBSD.org>2008-07-08 23:51:38 +0000
commite80b338f3b688d4192426fc44dd65e3d065dd500 (patch)
treed1beb4c0ee565d9d459ccdcd41b35cfa465e12b9 /sys/kern/link_elf_obj.c
parent12ebfa7cd90079ef782a97aec6c5abba52700845 (diff)
downloadFreeBSD-src-e80b338f3b688d4192426fc44dd65e3d065dd500.zip
FreeBSD-src-e80b338f3b688d4192426fc44dd65e3d065dd500.tar.gz
Improve the output of kldload(8) to show which module can't be loaded.
Was: kldload: Unsupported file type Is now: kldload: /boot/modules/test.ko: Unsupported file type PR: kern/121276 Submitted by: Edwin Groothuis <edwin@mavetju.org> Approved by: bde (mentor) MFC after: 1 week
Diffstat (limited to 'sys/kern/link_elf_obj.c')
-rw-r--r--sys/kern/link_elf_obj.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/sys/kern/link_elf_obj.c b/sys/kern/link_elf_obj.c
index f8ef7f3..e2ea863 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;
}
OpenPOWER on IntegriCloud