From a1d7ce03ea70fb29b37f07706534ac41f722d0f1 Mon Sep 17 00:00:00 2001 From: Attilio Rao Date: Tue, 10 Feb 2009 15:50:19 +0000 Subject: [PATCH] Scanning all the formats for binary translation of modules loading can result in errors for a format loading but subsequent correct recognizing for another format. File format loading functions should avoid printing any additional informations but just returning appropriate (and different between each other) error condition, characterizing different informations. Additively, the linker should handle appropriately different format loading errors. While a general mechanism is desired, fix a simple and common case on amd64: file type is not recognized for link elf and confuses the linker. Printout an error if all the registered linker classes can't recognize and load the module. Reviewed by: jhb Sponsored by: Sandvine Incorporated --- sys/kern/kern_linker.c | 8 ++++++++ sys/kern/link_elf.c | 6 ++---- sys/kern/link_elf_obj.c | 3 +-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/sys/kern/kern_linker.c b/sys/kern/kern_linker.c index 7805b0163fd..93507134da6 100644 --- a/sys/kern/kern_linker.c +++ b/sys/kern/kern_linker.c @@ -425,6 +425,14 @@ linker_load_file(const char *filename, linker_file_t *result) * the module was not found. */ if (foundfile) { + + /* + * If the file type has not been recognized by the last try + * printout a message before to fail. + */ + if (error == ENOSYS) + printf("linker_load_file: Unsupported file type\n"); + /* * Format not recognized or otherwise unloadable. * When loading a module that is statically built into diff --git a/sys/kern/link_elf.c b/sys/kern/link_elf.c index 52b3f8f0ba6..c17dd156135 100644 --- a/sys/kern/link_elf.c +++ b/sys/kern/link_elf.c @@ -638,8 +638,7 @@ link_elf_load_file(linker_class_t cls, const char* filename, goto out; } if (hdr->e_type != ET_EXEC && hdr->e_type != ET_DYN) { - link_elf_error(filename, "Unsupported file type"); - error = ENOEXEC; + error = ENOSYS; goto out; } if (hdr->e_machine != ELF_TARG_MACH) { @@ -694,8 +693,7 @@ link_elf_load_file(linker_class_t cls, const char* filename, break; case PT_INTERP: - link_elf_error(filename, "Unsupported file type"); - error = ENOEXEC; + error = ENOSYS; goto out; } diff --git a/sys/kern/link_elf_obj.c b/sys/kern/link_elf_obj.c index 29165fe0fe9..77347455324 100644 --- a/sys/kern/link_elf_obj.c +++ b/sys/kern/link_elf_obj.c @@ -474,8 +474,7 @@ link_elf_load_file(linker_class_t cls, const char *filename, goto out; } if (hdr->e_type != ET_REL) { - link_elf_error(filename, "Unsupported file type"); - error = ENOEXEC; + error = ENOSYS; goto out; } if (hdr->e_machine != ELF_TARG_MACH) {