Date: Wed, 26 Apr 2023 15:15:09 +0300 From: Konstantin Belousov <kostikbel@gmail.com> To: Hans Petter Selasky <hselasky@freebsd.org> Cc: Zhenlei Huang <zlei@freebsd.org>, FreeBSD CURRENT <freebsd-current@freebsd.org>, Gleb Smirnoff <glebius@freebsd.org> Subject: Re: Link modules to DYN type Message-ID: <ZEkVzcdYuh_MkDZm@kib.kiev.ua> In-Reply-To: <f200bce7-add8-6aff-38cf-2ee15dc35411@freebsd.org> References: <97390FE1-1DF5-43A1-A3F4-2B945D681437@FreeBSD.org> <2bb66cac-c7f1-e45b-693a-8afbda05cfa6@freebsd.org> <ZEkHKJ_BRhV22gf_@kib.kiev.ua> <f200bce7-add8-6aff-38cf-2ee15dc35411@freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Apr 26, 2023 at 01:38:32PM +0200, Hans Petter Selasky wrote: > On 4/26/23 13:12, Konstantin Belousov wrote: > > No, in-kernel linker does not behave this way. > > Modules need to contain explicit reference to all modules they depend upon, > > using the MODULE_DEPEND() macro. Only symbols from the dependencies are > > resolved. > > > > All modules get an implicit reference to kernel. > > Hi Konstantin, > > Maybe I wasn't so clear. Trying again: > > > diff --git a/sys/tests/ktest.c b/sys/tests/ktest.c > > index 495fedf95dde..eb42cf062487 100644 > > --- a/sys/tests/ktest.c > > +++ b/sys/tests/ktest.c > > @@ -409,6 +409,12 @@ static moduledata_t ktestmod = { > > 0 > > }; > > +int > > +printf(const char *fmt, ...) > > +{ > > + return (0); > > +} > > + > > DECLARE_MODULE(ktestmod, ktestmod, SI_SUB_PSEUDO, SI_ORDER_ANY); > > MODULE_VERSION(ktestmod, 1); > > MODULE_DEPEND(ktestmod, netlink, 1, 1, 1); > > Then kldload ktest.ko . Which printf() function will be used if ktest.c > calls printf() ? My best guess is that printf is resolved locally by the static linker, even before the module is loaded. In other words, it would be ktest.c printf. > > I would expect a warning from the kernel at least ... This is not how ELF behaves, even in such not fully compliant env as kernel.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?ZEkVzcdYuh_MkDZm>