Date: Fri, 28 Apr 2023 00:32:12 +0800 From: Zhenlei Huang <zlei@FreeBSD.org> To: Konstantin Belousov <kostikbel@gmail.com> Cc: Hans Petter Selasky <hselasky@freebsd.org>, FreeBSD CURRENT <freebsd-current@freebsd.org>, Gleb Smirnoff <glebius@freebsd.org> Subject: Re: Link modules to DYN type Message-ID: <86DC0C8E-56E8-49B9-8441-D64C690FA5F0@FreeBSD.org> In-Reply-To: <ZEkHKJ_BRhV22gf_@kib.kiev.ua> References: <97390FE1-1DF5-43A1-A3F4-2B945D681437@FreeBSD.org> <2bb66cac-c7f1-e45b-693a-8afbda05cfa6@freebsd.org> <ZEkHKJ_BRhV22gf_@kib.kiev.ua>
index | next in thread | previous in thread | raw e-mail
[-- Attachment #1 --] > On Apr 26, 2023, at 7:12 PM, Konstantin Belousov <kostikbel@gmail.com> wrote: > > On Wed, Apr 26, 2023 at 12:55:02PM +0200, Hans Petter Selasky wrote: >> On 4/26/23 12:36, Zhenlei Huang wrote: >>> Hi, >>> >>> I'm recently working on https://reviews.freebsd.org/D39638 (sysctl(9): Enable vnet sysctl variables be loader tunable), >>> the changes to `sys/kern/link_elf_obj.c` are runtime tested, but not those to `sys/kern/link_elf.c` . >>> >>> After some hacking I realized that `link_elf.c` is for EXEC (Executable file) or DYN (Shared object file), and `link_elf_obj.c` is >>> for REL (Relocatable file). >>> >>> ``` >>> /* link_elf.c */ >>> static int >>> link_elf_load_file(linker_class_t cls, const char* filename, >>> linker_file_t* result) >>> { >>> ... >>> if (hdr->e_type != ET_EXEC && hdr->e_type != ET_DYN) { >>> error = ENOSYS; >>> goto out; >>> } >>> ... >>> } >>> >>> >>> /* link_elf_obj.c */ >>> static int >>> link_elf_load_file(linker_class_t cls, const char *filename, >>> linker_file_t *result) >>> { >>> ... >>> if (hdr->e_type != ET_REL) { >>> error = ENOSYS; >>> goto out; >>> } >>> ... >>> } >>> ``` >>> >>> Run the following snip: >>> ``` >>> # find /boot/kernel -type f -name "*.ko" -exec readelf -h {} \; | grep Type >>> ``` >>> shows that all the kernel modules' types are `REL (Relocatable file)`. >>> >>> I guess if some module such as if_bridge is linked to DYN type, then I can do runtime for the changes to `sys/kern/link_elf.c`. >>> >>> I'm not familiar with elf and linkers, is that ( compile module and link it to DYN type ) possible ? > > Module file type (shared object vs. object file) depends on architecture. > For amd64 modules are objects, while kernel is shared library. > For arm64 (and all other arches, I believe) modules and kernels are shared > libraries. > > I think you can link amd64 module as shared object, but this require enough > hacking of the build infrastructure. At least I am not aware of a simple > knob to switch the produced type. I did some hack on `sys/conf/kmod.mk` and finally produced DYN kernel modules. The good news is I do some basic sysctl tests, but the bad news is the module does not function correctly. For exampe the if_disc.c ``` static void vnet_disc_init(const void *unused __unused) { /* Reference V_disc_cloner will immediately trigger page fault panic */ V_disc_cloner = if_clone_simple(discname, disc_clone_create, disc_clone_destroy, 0); } VNET_SYSINIT(vnet_disc_init, SI_SUB_PSEUDO, SI_ORDER_ANY, vnet_disc_init, NULL); ``` I suspect the relocation is not done correctly for DYN elf kmod on amd64. My local patch to kmod.mk: ``` diff --git a/sys/conf/kmod.mk b/sys/conf/kmod.mk index 134b150af1d9..1fc5386204a5 100644 --- a/sys/conf/kmod.mk +++ b/sys/conf/kmod.mk @@ -84,6 +84,7 @@ __KLD_SHARED=yes .else __KLD_SHARED=no .endif +__KLD_SHARED=yes .if !empty(CFLAGS:M-O[23s]) && empty(CFLAGS:M-fno-strict-aliasing) CFLAGS+= -fno-strict-aliasing @@ -167,6 +168,7 @@ CFLAGS+= -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer ${MACHINE_CPUARCH} == "powerpc" CFLAGS+= -fPIC .endif +CFLAGS+= -fPIC # Temporary workaround for PR 196407, which contains the fascinating details. # Don't allow clang to use fpu instructions or registers in kernel modules. ``` As for https://reviews.freebsd.org/D39638 <https://reviews.freebsd.org/D39638>, for other platform such as arm, I think the `link_elf_propagate_vnets()` should work if `parse_vnet()` works. I'll appreciate if someone can test it on platforms those have DYN type kernel modules. > > >>> >> >> Hi, >> >> I don't have an answer for you either, but I have seen in the past, loading >> kernel modules behaves a bit like libraries, in the following regard: >> >> If two kernel modules define the same global symbol, then no warning is >> given and the first loaded symbol definition (I think) is used to resolve >> that symbol for all kernel modules, regardless of the prototype. Probably we >> should not allow this. That's why building LINT is a good thing, to avoid >> this issue. > 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. > >> >> Even if we don't have C++ support in the FreeBSD kernel, defining symbol >> names the way C++ does for C could be nice for the kernel too, also with >> regards to debugging systems. >> >> Many times when I don't know what is going on, I do like this: >> >> #include <sys/kdb.h> >> >> .... >> >> if (not too fast or my sysctl debug) { >> printf("My tracer\n"); >> kdb_backtrace(); >> } >> >> Dtrace can also do this, but not during boot. Just track who is calling >> those functions, and you'll probably find the answer to your question! >> >> --HPS >> >>> >>> Best regards, >>> Zhenlei [-- Attachment #2 --] <html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Apr 26, 2023, at 7:12 PM, Konstantin Belousov <<a href="mailto:kostikbel@gmail.com" class="">kostikbel@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta charset="UTF-8" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">On Wed, Apr 26, 2023 at 12:55:02PM +0200, Hans Petter Selasky wrote:</span><br style="caret-color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><blockquote type="cite" style="font-family: Menlo-Regular; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">On 4/26/23 12:36, Zhenlei Huang wrote:<br class=""><blockquote type="cite" class="">Hi,<br class=""><br class="">I'm recently working on <a href="https://reviews.freebsd.org/D39638" class="">https://reviews.freebsd.org/D39638</a> (sysctl(9): Enable vnet sysctl variables be loader tunable),<br class="">the changes to `sys/kern/link_elf_obj.c` are runtime tested, but not those to `sys/kern/link_elf.c` .<br class=""><br class="">After some hacking I realized that `link_elf.c` is for EXEC (Executable file) or DYN (Shared object file), and `link_elf_obj.c` is<br class="">for REL (Relocatable file).<br class=""><br class="">```<br class="">/* link_elf.c */<br class="">static int<br class="">link_elf_load_file(linker_class_t cls, const char* filename,<br class=""> linker_file_t* result)<br class="">{<br class="">...<br class=""><span class="Apple-tab-span" style="white-space: pre;"> </span>if (hdr->e_type != ET_EXEC && hdr->e_type != ET_DYN) {<br class=""><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>error = ENOSYS;<br class=""><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>goto out;<br class=""><span class="Apple-tab-span" style="white-space: pre;"> </span>}<br class="">...<br class="">}<br class=""><br class=""><br class="">/* link_elf_obj.c */<br class="">static int<br class="">link_elf_load_file(linker_class_t cls, const char *filename,<br class=""> linker_file_t *result)<br class="">{<br class="">...<br class=""><span class="Apple-tab-span" style="white-space: pre;"> </span>if (hdr->e_type != ET_REL) {<br class=""><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>error = ENOSYS;<br class=""><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>goto out;<br class=""><span class="Apple-tab-span" style="white-space: pre;"> </span>}<br class="">...<br class="">}<br class="">```<br class=""><br class="">Run the following snip:<br class="">```<br class=""># find /boot/kernel -type f -name "*.ko" -exec readelf -h {} \; | grep Type<br class="">```<br class="">shows that all the kernel modules' types are `REL (Relocatable file)`.<br class=""><br class="">I guess if some module such as if_bridge is linked to DYN type, then I can do runtime for the changes to `sys/kern/link_elf.c`.<br class=""><br class="">I'm not familiar with elf and linkers, is that ( compile module and link it to DYN type ) possible ?<br class=""></blockquote></blockquote><br style="caret-color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">Module file type (shared object vs. object file) depends on architecture.</span><br style="caret-color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">For amd64 modules are objects, while kernel is shared library.</span><br style="caret-color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">For arm64 (and all other arches, I believe) modules and kernels are shared</span><br style="caret-color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">libraries.</span></div></blockquote><blockquote type="cite" class=""><div class=""><br style="caret-color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">I think you can link amd64 module as shared object, but this require enough</span><br style="caret-color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">hacking of the build infrastructure. At least I am not aware of a simple</span><br style="caret-color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">knob to switch the produced type.</span><br style="caret-color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""></div></blockquote><div><br class=""></div><div><div style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);">I did some hack on `sys/conf/kmod.mk` and finally produced DYN kernel modules.</div><div style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);">The good news is I do some basic sysctl tests, but the bad news is the module does not function correctly.</div><div style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);"><br class=""></div><div style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);">For exampe the if_disc.c</div><div style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);"><br class=""></div><div style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);">```</div><div><div><font color="#000000" class=""><span style="caret-color: rgb(0, 0, 0);" class="">static void</span></font></div><div><font color="#000000" class=""><span style="caret-color: rgb(0, 0, 0);" class="">vnet_disc_init(const void *unused __unused)</span></font></div><div><font color="#000000" class=""><span style="caret-color: rgb(0, 0, 0);" class="">{</span></font></div><div><span class="Apple-tab-span" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); white-space: pre;"> </span>/* Reference V_disc_cloner will immediately trigger page fault panic */</div><div><font color="#000000" class=""><span style="caret-color: rgb(0, 0, 0);" class=""><span class="Apple-tab-span" style="white-space:pre"> </span>V_disc_cloner = if_clone_simple(discname, disc_clone_create,</span></font></div><div><font color="#000000" class=""><span style="caret-color: rgb(0, 0, 0);" class=""><span class="Apple-tab-span" style="white-space:pre"> </span> disc_clone_destroy, 0);</span></font></div><div><font color="#000000" class=""><span style="caret-color: rgb(0, 0, 0);" class="">}</span></font></div><div><font color="#000000" class=""><span style="caret-color: rgb(0, 0, 0);" class="">VNET_SYSINIT(vnet_disc_init, SI_SUB_PSEUDO, SI_ORDER_ANY,</span></font></div><div><font color="#000000" class=""><span style="caret-color: rgb(0, 0, 0);" class=""> vnet_disc_init, NULL);</span></font></div></div><div style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);">```</div><div style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);"><br class=""></div></div><div>I suspect the relocation is not done correctly for <span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class="">DYN elf kmod on amd64.</span></div><div><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class=""><br class=""></span></div><div><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class="">My local patch to kmod.mk:</span></div><div><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class=""><br class=""></span></div><div><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class="">```</span></div><div><div><font color="#000000" class=""><span style="caret-color: rgb(0, 0, 0);" class="">diff --git a/sys/conf/kmod.mk b/sys/conf/kmod.mk</span></font></div><div><font color="#000000" class=""><span style="caret-color: rgb(0, 0, 0);" class="">index 134b150af1d9..1fc5386204a5 100644</span></font></div><div><font color="#000000" class=""><span style="caret-color: rgb(0, 0, 0);" class="">--- a/sys/conf/kmod.mk</span></font></div><div><font color="#000000" class=""><span style="caret-color: rgb(0, 0, 0);" class="">+++ b/sys/conf/kmod.mk</span></font></div><div><font color="#000000" class=""><span style="caret-color: rgb(0, 0, 0);" class="">@@ -84,6 +84,7 @@ __KLD_SHARED=yes</span></font></div><div><font color="#000000" class=""><span style="caret-color: rgb(0, 0, 0);" class=""> .else</span></font></div><div><font color="#000000" class=""><span style="caret-color: rgb(0, 0, 0);" class=""> __KLD_SHARED=no</span></font></div><div><font color="#000000" class=""><span style="caret-color: rgb(0, 0, 0);" class=""> .endif</span></font></div><div><font color="#000000" class=""><span style="caret-color: rgb(0, 0, 0);" class="">+__KLD_SHARED=yes</span></font></div><div><font color="#000000" class=""><span style="caret-color: rgb(0, 0, 0);" class=""> </span></font></div><div><font color="#000000" class=""><span style="caret-color: rgb(0, 0, 0);" class=""> .if !empty(CFLAGS:M-O[23s]) && empty(CFLAGS:M-fno-strict-aliasing)</span></font></div><div><font color="#000000" class=""><span style="caret-color: rgb(0, 0, 0);" class=""> CFLAGS+= -fno-strict-aliasing</span></font></div><div><font color="#000000" class=""><span style="caret-color: rgb(0, 0, 0);" class="">@@ -167,6 +168,7 @@ CFLAGS+= -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer</span></font></div><div><font color="#000000" class=""><span style="caret-color: rgb(0, 0, 0);" class=""> ${MACHINE_CPUARCH} == "powerpc"</span></font></div><div><font color="#000000" class=""><span style="caret-color: rgb(0, 0, 0);" class=""> CFLAGS+= -fPIC</span></font></div><div><font color="#000000" class=""><span style="caret-color: rgb(0, 0, 0);" class=""> .endif</span></font></div><div><font color="#000000" class=""><span style="caret-color: rgb(0, 0, 0);" class="">+CFLAGS+= -fPIC</span></font></div><div><font color="#000000" class=""><span style="caret-color: rgb(0, 0, 0);" class=""> </span></font></div><div><font color="#000000" class=""><span style="caret-color: rgb(0, 0, 0);" class=""> # Temporary workaround for PR 196407, which contains the fascinating details.</span></font></div><div><font color="#000000" class=""><span style="caret-color: rgb(0, 0, 0);" class=""> # Don't allow clang to use fpu instructions or registers in kernel modules.</span></font></div></div><div><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class="">```</span></div><div><br class=""></div><div><br class=""></div><div>As for <a href="https://reviews.freebsd.org/D39638" class="">https://reviews.freebsd.org/D39638</a>, for other platform such as arm, I think the `link_elf_propagate_vnets()` should work if `parse_vnet()` works.</div><div><br class=""></div><div>I'll appreciate if someone can test it on platforms those have DYN type kernel modules. </div><br class=""><blockquote type="cite" class=""><div class=""><br style="caret-color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br style="caret-color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><blockquote type="cite" style="font-family: Menlo-Regular; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><blockquote type="cite" class=""><br class=""></blockquote><br class="">Hi,<br class=""><br class="">I don't have an answer for you either, but I have seen in the past, loading<br class="">kernel modules behaves a bit like libraries, in the following regard:<br class=""><br class="">If two kernel modules define the same global symbol, then no warning is<br class="">given and the first loaded symbol definition (I think) is used to resolve<br class="">that symbol for all kernel modules, regardless of the prototype. Probably we<br class="">should not allow this. That's why building LINT is a good thing, to avoid<br class="">this issue.<br class=""></blockquote><span style="caret-color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">No, in-kernel linker does not behave this way.</span><br style="caret-color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">Modules need to contain explicit reference to all modules they depend upon,</span><br style="caret-color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">using the MODULE_DEPEND() macro. Only symbols from the dependencies are</span><br style="caret-color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">resolved.</span><br style="caret-color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br style="caret-color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">All modules get an implicit reference to kernel.</span><br style="caret-color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br style="caret-color: rgb(0, 0, 0); font-family: Menlo-Regular; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><blockquote type="cite" style="font-family: Menlo-Regular; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br class="">Even if we don't have C++ support in the FreeBSD kernel, defining symbol<br class="">names the way C++ does for C could be nice for the kernel too, also with<br class="">regards to debugging systems.<br class=""><br class="">Many times when I don't know what is going on, I do like this:<br class=""><br class="">#include <sys/kdb.h><br class=""><br class="">....<br class=""><br class="">if (not too fast or my sysctl debug) {<br class=""> printf("My tracer\n");<br class=""> kdb_backtrace();<br class="">}<br class=""><br class="">Dtrace can also do this, but not during boot. Just track who is calling<br class="">those functions, and you'll probably find the answer to your question!<br class=""><br class="">--HPS<br class=""><br class=""><blockquote type="cite" class=""><br class="">Best regards,<br class="">Zhenlei</blockquote></blockquote></div></blockquote></div><br class=""><div class=""> <div><br class=""></div> </div> <br class=""></body></html>home | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?86DC0C8E-56E8-49B9-8441-D64C690FA5F0>
