From nobody Wed Apr 26 12:15:09 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 4Q5yVt4hznz47vMf for ; Wed, 26 Apr 2023 12:15:18 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4Q5yVs6bDnz414K; Wed, 26 Apr 2023 12:15:17 +0000 (UTC) (envelope-from kostikbel@gmail.com) Authentication-Results: mx1.freebsd.org; none Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.17.1/8.17.1) with ESMTPS id 33QCFANk032806 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 26 Apr 2023 15:15:13 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua 33QCFANk032806 Received: (from kostik@localhost) by tom.home (8.17.1/8.17.1/Submit) id 33QCF9l5032787; Wed, 26 Apr 2023 15:15:09 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Wed, 26 Apr 2023 15:15:09 +0300 From: Konstantin Belousov To: Hans Petter Selasky Cc: Zhenlei Huang , FreeBSD CURRENT , Gleb Smirnoff Subject: Re: Link modules to DYN type Message-ID: References: <97390FE1-1DF5-43A1-A3F4-2B945D681437@FreeBSD.org> <2bb66cac-c7f1-e45b-693a-8afbda05cfa6@freebsd.org> 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 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=4.0.0 X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-14) on tom.home X-Rspamd-Queue-Id: 4Q5yVs6bDnz414K X-Spamd-Bar: ---- X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:6939, ipnet:2001:470::/32, country:US] X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-ThisMailContainsUnwantedMimeParts: N 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.