From owner-freebsd-hackers@freebsd.org Thu Sep 6 11:58:01 2018 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 95504FF89BA for ; Thu, 6 Sep 2018 11:58:01 +0000 (UTC) (envelope-from eugen@grosbein.net) Received: from hz.grosbein.net (hz.grosbein.net [IPv6:2a01:4f8:d12:604::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "hz.grosbein.net", Issuer "hz.grosbein.net" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 05E2B730F4 for ; Thu, 6 Sep 2018 11:58:00 +0000 (UTC) (envelope-from eugen@grosbein.net) Received: from eg.sd.rdtc.ru (eg.sd.rdtc.ru [IPv6:2a03:3100:c:13:0:0:0:5]) by hz.grosbein.net (8.15.2/8.15.2) with ESMTPS id w86Bvr9h099744 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 6 Sep 2018 13:57:54 +0200 (CEST) (envelope-from eugen@grosbein.net) X-Envelope-From: eugen@grosbein.net X-Envelope-To: freebsduser@gmx.com Received: from eg.sd.rdtc.ru (eugen@localhost [127.0.0.1]) by eg.sd.rdtc.ru (8.15.2/8.15.2) with ESMTP id w86BvnDa013654; Thu, 6 Sep 2018 18:57:49 +0700 (+07) (envelope-from eugen@grosbein.net) Subject: Re: kernel module linking (general, ipfw table, netgraph) To: freeuser , freebsd-hackers@freebsd.org References: From: Eugene Grosbein X-Enigmail-Draft-Status: N1110 Message-ID: <5B91163D.9030905@grosbein.net> Date: Thu, 6 Sep 2018 18:57:49 +0700 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=koi8-r Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=0.3 required=5.0 tests=BAYES_00, DATE_IN_FUTURE_96_Q, LOCAL_FROM, SPF_PASS autolearn=no autolearn_force=no version=3.4.1 X-Spam-Report: * -0.0 SPF_PASS SPF: sender matches SPF record * 0.0 DATE_IN_FUTURE_96_Q Date: is 4 days to 4 months after Received: date * -2.3 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] * 2.6 LOCAL_FROM From my domains X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on hz.grosbein.net X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 06 Sep 2018 11:58:01 -0000 On 06.09.2018 19:02, freeuser wrote: > Hello, > > I'm working on a netgraph kernel module that modifies ipfw table contents. > But i can not load the module, because > kldload: an error occurred while loading the module. Please check > dmesg(8) > for more details. > > dmesg informs: > .. > link_elf_obj: symbol add_table_entry undefined > linker_load_file: Unsupported file type > > add_table_entry is a function that modifies ipfw table, the thing is that i > have included the relevant header files, but i don't understand how > should i > deal with linking. I assumed that this function will be available for > module > since "sysctl -b kern.function_list | tr '\0' '\n' | grep add_table" shows > it. > > I am building my module using /usr/src/sys/modules/netgraph/sample and > /usr/src/sys/netgraph/ng_sample.* as templates. On the other hand, > ng_socket > uses kern_kldload, "sysctl -b kern.function_list | tr '\0' '\n' | grep > kern_kldload" > shows it and it works without any problems. > > Why is that? What have i not noticed that must be done? Perhaps, this is KBI mismatch due to VIMAGE kernel option that changes symbols like add_table_entry to V_add_table_entry and your kernel module should be built WITH_VIMAGE defined too to be loadable to such a kernel.