summaryrefslogtreecommitdiffstats
path: root/sys/kern/link_elf.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/kern/link_elf.c')
-rw-r--r--sys/kern/link_elf.c25
1 files changed, 14 insertions, 11 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;
}
OpenPOWER on IntegriCloud