summaryrefslogtreecommitdiffstats
path: root/sys/kern
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
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')
-rw-r--r--sys/kern/link_elf.c25
-rw-r--r--sys/kern/link_elf_obj.c21
2 files changed, 26 insertions, 20 deletions
diff --git a/sys/kern/link_elf.c b/sys/kern/link_elf.c
index bdaa636..2664ba9 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 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