From owner-svn-src-all@FreeBSD.ORG Tue Feb 10 15:50:19 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EAB841065677; Tue, 10 Feb 2009 15:50:19 +0000 (UTC) (envelope-from attilio@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BEBA48FC25; Tue, 10 Feb 2009 15:50:19 +0000 (UTC) (envelope-from attilio@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n1AFoJjJ097640; Tue, 10 Feb 2009 15:50:19 GMT (envelope-from attilio@svn.freebsd.org) Received: (from attilio@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n1AFoJoj097637; Tue, 10 Feb 2009 15:50:19 GMT (envelope-from attilio@svn.freebsd.org) Message-Id: <200902101550.n1AFoJoj097637@svn.freebsd.org> From: Attilio Rao Date: Tue, 10 Feb 2009 15:50:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188440 - head/sys/kern X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Feb 2009 15:50:20 -0000 Author: attilio Date: Tue Feb 10 15:50:19 2009 New Revision: 188440 URL: http://svn.freebsd.org/changeset/base/188440 Log: 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 Modified: head/sys/kern/kern_linker.c head/sys/kern/link_elf.c head/sys/kern/link_elf_obj.c Modified: head/sys/kern/kern_linker.c ============================================================================== --- head/sys/kern/kern_linker.c Tue Feb 10 15:11:26 2009 (r188439) +++ head/sys/kern/kern_linker.c Tue Feb 10 15:50:19 2009 (r188440) @@ -425,6 +425,14 @@ linker_load_file(const char *filename, l * 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 Modified: head/sys/kern/link_elf.c ============================================================================== --- head/sys/kern/link_elf.c Tue Feb 10 15:11:26 2009 (r188439) +++ head/sys/kern/link_elf.c Tue Feb 10 15:50:19 2009 (r188440) @@ -638,8 +638,7 @@ link_elf_load_file(linker_class_t cls, c 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, c break; case PT_INTERP: - link_elf_error(filename, "Unsupported file type"); - error = ENOEXEC; + error = ENOSYS; goto out; } Modified: head/sys/kern/link_elf_obj.c ============================================================================== --- head/sys/kern/link_elf_obj.c Tue Feb 10 15:11:26 2009 (r188439) +++ head/sys/kern/link_elf_obj.c Tue Feb 10 15:50:19 2009 (r188440) @@ -474,8 +474,7 @@ link_elf_load_file(linker_class_t cls, c 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) {