From nobody Wed Apr 26 12:19:18 2023 X-Original-To: freebsd-current@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Q5yc05h4dz47vZv for ; Wed, 26 Apr 2023 12:19:44 +0000 (UTC) (envelope-from janm@transactionware.com) Received: from mail3.transactionware.com (mail.transactionware.com [203.14.245.7]) by mx1.freebsd.org (Postfix) with SMTP id 4Q5ybz6NbMz42Hs for ; Wed, 26 Apr 2023 12:19:43 +0000 (UTC) (envelope-from janm@transactionware.com) Authentication-Results: mx1.freebsd.org; none Received: (qmail 25638 invoked by uid 907); 26 Apr 2023 12:19:35 -0000 Received: from i5E86410A.versanet.de (HELO smtpclient.apple) (94.134.65.10) (smtp-auth username janm, mechanism plain) by mail3.transactionware.com (qpsmtpd/0.84) with (ECDHE-RSA-AES256-GCM-SHA384 encrypted) ESMTPSA; Wed, 26 Apr 2023 22:19:35 +1000 From: Jan Martin Mikkelsen Message-Id: <72A678C8-4293-4D50-BCCC-AFE92DB1DA76@transactionware.com> Content-Type: multipart/alternative; boundary="Apple-Mail=_E0EC44FA-60CE-4567-819A-9C1C99260C8E" List-Id: Discussions about the use of FreeBSD-current List-Archive: https://lists.freebsd.org/archives/freebsd-current List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-current@freebsd.org Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.500.231\)) Subject: Re: Link modules to DYN type Date: Wed, 26 Apr 2023 14:19:18 +0200 In-Reply-To: Cc: Konstantin Belousov , Zhenlei Huang , FreeBSD CURRENT , Gleb Smirnoff To: Hans Petter Selasky References: <97390FE1-1DF5-43A1-A3F4-2B945D681437@FreeBSD.org> <2bb66cac-c7f1-e45b-693a-8afbda05cfa6@freebsd.org> X-Mailer: Apple Mail (2.3731.500.231) X-Rspamd-Queue-Id: 4Q5ybz6NbMz42Hs X-Spamd-Bar: ---- X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:17559, ipnet:203.14.245.0/24, country:AU] X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-ThisMailContainsUnwantedMimeParts: N --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 = 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

On 26. = Apr 2023, at 13:38, Hans Petter Selasky <hselasky@freebsd.org> = 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 = =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);

Then kldload ktest.ko . Which printf() function = will be used if ktest.c calls printf() ?

I would expect a warning = from the kernel at least = =E2=80=A6

Hi,

<= div>This looks similar to this:



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