Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 15 Jul 2010 21:18:23 +0300
From:      Kostik Belousov <kostikbel@gmail.com>
To:        Dmitry Krivenok <krivenok.dmitry@gmail.com>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: Kernel linker and undefined references in KLD
Message-ID:  <20100715181823.GX2381@deviant.kiev.zoral.com.ua>
In-Reply-To: <AANLkTinH8J3yVu6jw09ow7RTp1EFM0bGc94RL8ezy72-@mail.gmail.com>
References:  <AANLkTikhrbdbBEFl-I97nBzdvZx6qBaafDUsveRmYyp3@mail.gmail.com> <20100715143235.GU2381@deviant.kiev.zoral.com.ua> <AANLkTinH8J3yVu6jw09ow7RTp1EFM0bGc94RL8ezy72-@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help

--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--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20100715181823.GX2381>