Date: Wed, 26 Apr 2023 14:19:18 +0200 From: Jan Martin Mikkelsen <janm@transactionware.com> To: Hans Petter Selasky <hselasky@freebsd.org> Cc: Konstantin Belousov <kostikbel@gmail.com>, 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: <72A678C8-4293-4D50-BCCC-AFE92DB1DA76@transactionware.com> 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
--Apple-Mail=_E0EC44FA-60CE-4567-819A-9C1C99260C8E Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On 26. Apr 2023, at 13:38, Hans Petter Selasky <hselasky@freebsd.org> = wrote: >=20 > 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. >=20 > Hi Konstantin, >=20 > Maybe I wasn't so clear. Trying again: >=20 >> 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 =3D { >> 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); >=20 > Then kldload ktest.ko . Which printf() function will be used if = ktest.c calls printf() ? >=20 > I would expect a warning from the kernel at least =E2=80=A6 Hi, This looks similar to this: https://lists.freebsd.org/pipermail/freebsd-stable/2015-July/082751.html https://lists.freebsd.org/pipermail/freebsd-stable/2015-July/082760.html The =E2=80=9Cnot knowing=E2=80=9D about how symbols are going to be = resolved has bothered me for a while. Regards, Jan M. --Apple-Mail=_E0EC44FA-60CE-4567-819A-9C1C99260C8E Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 <html><head><meta http-equiv=3D"content-type" content=3D"text/html; = charset=3Dutf-8"></head><body style=3D"overflow-wrap: break-word; = -webkit-nbsp-mode: space; line-break: = after-white-space;"><br><div><br><blockquote type=3D"cite"><div>On 26. = Apr 2023, at 13:38, Hans Petter Selasky <hselasky@freebsd.org> = wrote:</div><br class=3D"Apple-interchange-newline"><div><div>On 4/26/23 = 13:12, Konstantin Belousov wrote:<br><blockquote type=3D"cite">No, = in-kernel linker does not behave this way.<br>Modules need to contain = explicit reference to all modules they depend upon,<br>using the = MODULE_DEPEND() macro. Only symbols from the dependencies = are<br>resolved.<br>All modules get an implicit reference to = kernel.<br></blockquote><br>Hi Konstantin,<br><br>Maybe I wasn't so = clear. Trying again:<br><br><blockquote type=3D"cite">diff --git = a/sys/tests/ktest.c b/sys/tests/ktest.c<br>index = 495fedf95dde..eb42cf062487 100644<br>--- a/sys/tests/ktest.c<br>+++ = b/sys/tests/ktest.c<br>@@ -409,6 +409,12 @@ static moduledata_t ktestmod = =3D {<br> 0<br> };<br> = +int<br>+printf(const char *fmt, ...)<br>+{<br>+ = return (0);<br>+}<br>+<br> = DECLARE_MODULE(ktestmod, ktestmod, SI_SUB_PSEUDO, SI_ORDER_ANY);<br> = MODULE_VERSION(ktestmod, 1);<br> MODULE_DEPEND(ktestmod, netlink, 1, 1, = 1);<br></blockquote><br>Then kldload ktest.ko . Which printf() function = will be used if ktest.c calls printf() ?<br><br>I would expect a warning = from the kernel at least = =E2=80=A6</div></div></blockquote></div><div><br></div>Hi,<div><br></div><= div>This looks similar to this:</div><div><br></div><div><a = href=3D"https://lists.freebsd.org/pipermail/freebsd-stable/2015-July/08275= 1.html">https://lists.freebsd.org/pipermail/freebsd-stable/2015-July/08275= 1.html</a></div><div><br></div><div><a = href=3D"https://lists.freebsd.org/pipermail/freebsd-stable/2015-July/08276= 0.html">https://lists.freebsd.org/pipermail/freebsd-stable/2015-July/08276= 0.html</a></div><div><br></div><div>The =E2=80=9Cnot knowing=E2=80=9D = about how symbols are going to be resolved has bothered me for a = while.</div><div><br><div>Regards,</div></div><div><br></div><div>Jan = M.</div><div><br></div></body></html>= --Apple-Mail=_E0EC44FA-60CE-4567-819A-9C1C99260C8E--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?72A678C8-4293-4D50-BCCC-AFE92DB1DA76>