From owner-freebsd-hackers@FreeBSD.ORG Thu Jul 15 18:18:30 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 348131065686 for ; Thu, 15 Jul 2010 18:18:30 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id 9C7738FC29 for ; Thu, 15 Jul 2010 18:18:29 +0000 (UTC) Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua [10.1.1.148]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id o6FIINdc019061 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 15 Jul 2010 21:18:23 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4) with ESMTP id o6FIINYg007710; Thu, 15 Jul 2010 21:18:23 +0300 (EEST) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4/Submit) id o6FIINSJ007709; Thu, 15 Jul 2010 21:18:23 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Thu, 15 Jul 2010 21:18:23 +0300 From: Kostik Belousov To: Dmitry Krivenok Message-ID: <20100715181823.GX2381@deviant.kiev.zoral.com.ua> References: <20100715143235.GU2381@deviant.kiev.zoral.com.ua> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="jn/MQTzma+jNUHFC" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-2.3 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_50, DNS_FROM_OPENWHOIS autolearn=no version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: freebsd-hackers@freebsd.org Subject: Re: Kernel linker and undefined references in KLD X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Jul 2010 18:18:30 -0000 --jn/MQTzma+jNUHFC Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Jul 15, 2010 at 10:13:54PM +0400, Dmitry Krivenok wrote: > Unfortunately, one can easily miss such problems during build of the modu= le. > I'm working on a system which consists of lots of user-space programs > and kernel modules and > uses it's own complicated build system. > gcc option -Werror is not used by the build system (I believe it > should), that's why we just missed > a compiler warning when called undeclared function (actually declared > as static deep in kernel source). >=20 > Then we got kernel panic and started investigating it. > I disassembled seltdinit function and found that it takes pointer to > thread from %eax register and global kernel > functions (e.g. kern_select) calling seltdinit copy the pointer to > %eax just before "call" instruction. >=20 > Then I disassembled my own function calling seltdinit and found that > it passes the pointer via stack and > doesn't do anything with %eax register. >=20 > I'm not OS/compilers/ASM expert, but I guess that gcc is free to > optimize passing of parameters to static functions > because it has all the information about callers of these static > functions (all stuff is inside one translation unit). > So kernel functions call static functions in a right way, but modules > compiled separately may use wrong calling > convention. Your message does not contain the question, but right answer is that you should not call static functions. --jn/MQTzma+jNUHFC Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (FreeBSD) iEYEARECAAYFAkw/UO8ACgkQC3+MBN1Mb4jasACaAiWFcsVIS4oembr8K0+bYKR/ jhMAnjor+jwXCBIciTiQDpMJPt8psLKK =Mx2q -----END PGP SIGNATURE----- --jn/MQTzma+jNUHFC--