From owner-freebsd-hackers@FreeBSD.ORG Wed Jun 23 15:40:46 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3DC72106566C; Wed, 23 Jun 2010 15:40:46 +0000 (UTC) (envelope-from avg@icyb.net.ua) Received: from citadel.icyb.net.ua (citadel.icyb.net.ua [212.40.38.140]) by mx1.freebsd.org (Postfix) with ESMTP id 485D68FC14; Wed, 23 Jun 2010 15:40:44 +0000 (UTC) Received: from odyssey.starpoint.kiev.ua (alpha-e.starpoint.kiev.ua [212.40.38.101]) by citadel.icyb.net.ua (8.8.8p3/ICyb-2.3exp) with ESMTP id SAA28330; Wed, 23 Jun 2010 18:40:30 +0300 (EEST) (envelope-from avg@icyb.net.ua) Message-ID: <4C222AED.2070802@icyb.net.ua> Date: Wed, 23 Jun 2010 18:40:29 +0300 From: Andriy Gapon User-Agent: Thunderbird 2.0.0.24 (X11/20100517) MIME-Version: 1.0 To: Ryan Stone References: <201006230238.06831.hselasky@c2i.net> <4C21AE18.4050400@icyb.net.ua> <201006230852.26536.hselasky@c2i.net> <4C21B170.2030903@icyb.net.ua> <4C21B383.2000602@icyb.net.ua> In-Reply-To: X-Enigmail-Version: 0.95.7 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: freebsd-hackers@freebsd.org, freebsd-current@freebsd.org, Hans Petter Selasky Subject: Re: [HEADS UP] Kernel modules don't work properly in FreeBSD 8.1-RC1 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Jun 2010 15:40:46 -0000 on 23/06/2010 18:03 Ryan Stone said the following: > On Wed, Jun 23, 2010 at 3:10 AM, Andriy Gapon wrote: >> Which also brings the question - what arch(s) is affected? >> I tested on amd64. > > This should explain it. It looks to me like i386 uses kern/link_elf.c > as its linker, while amd64 uses kern/link_elf_obj.c. link_elf.c can > only find the sections containing the sysinits(and some related > things) via the magic symbols. link_elf_obj.c seems to understand ELF > objects much better and doesn't need those symbols to be present. It > just looks up the section that contains the sysinits directly via the > ELF metadata that is already present. Yes, you are absolutely correct. This comes from the fact that amd64 uses simple objects files (aka .o) as kernel modules and i386 uses full-blow dso. > As far as I can tell, amd64 is the only arch in the tree that uses > link_elf_obj.c, so all other arches may be affected. > > I have to admit that I'm more than a little surprised that this > problem does not affect modules that in src, but maybe that's because > I don't know all that much about FreeBSD's build infrastructure. Are > the src modules being linked with a linker script that is not being > used for out-of-src modules? No, we don't have any special linker script for modules. > Are the people affected by this not > using the base compiler to build ports?(I see that this affects PC-BSD > as well, and I'd be a little surprised to learn that it wasn't using > the base compiler). I think that even out-of-base modules still use the same module build infrastructure (bsd.kmod.mk). At least this is the case for cuse4bsd. > The link line that I gave was a hack. The proper solution is to use a > linker script that unconditionally puts the magic symbols in. Module link process on i386 is like this (simplified): 1) combine object files into a single object file mod.kld ld -r -o mod.kld 1.o 2.o 2) convert it to dso ld -Bshareable -d -warn-common -o mod.ko mod.kld I believe that __start/__stop symbols for sections should be automatically added at step 2 by linker. Reference: http://sourceware.org/binutils/docs/ld/Orphan-Sections.html#Orphan-Sections -- Andriy Gapon