From owner-freebsd-hackers@FreeBSD.ORG Tue Jun 22 21:32:17 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 2DD5A106564A for ; Tue, 22 Jun 2010 21:32:17 +0000 (UTC) (envelope-from faber@zod.isi.edu) Received: from zod.isi.edu (zod.isi.edu [128.9.168.221]) by mx1.freebsd.org (Postfix) with ESMTP id 002478FC21 for ; Tue, 22 Jun 2010 21:32:16 +0000 (UTC) Received: from zod.isi.edu (localhost [127.0.0.1]) by zod.isi.edu (8.14.4/8.14.4) with ESMTP id o5ML7N8r021850; Tue, 22 Jun 2010 14:07:23 -0700 (PDT) (envelope-from faber@zod.isi.edu) Received: (from faber@localhost) by zod.isi.edu (8.14.4/8.14.4/Submit) id o5ML7LGU021849; Tue, 22 Jun 2010 14:07:21 -0700 (PDT) (envelope-from faber) Date: Tue, 22 Jun 2010 14:07:21 -0700 From: Ted Faber To: Ryan Stone Message-ID: <20100622210721.GC18012@zod.isi.edu> References: <201003301510.58203.jhb@freebsd.org> <87bpe4ps9m.fsf@kobe.laptop> <201006222208.23271.hselasky@c2i.net> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="c3bfwLpm8qysLVxt" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.3i X-url: http://www.isi.edu/~faber Cc: Bruce Cran , "Sergey V. Dyatko" , freebsd-hackers@freebsd.org, Hans Petter Selasky , Alexander Best , freebsd-current@freebsd.org, Giorgos Keramidas Subject: Re: building world with debugging symbols [broken?] 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: Tue, 22 Jun 2010 21:32:17 -0000 --c3bfwLpm8qysLVxt Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Jun 22, 2010 at 04:39:17PM -0400, Ryan Stone wrote: > I saw similar behaviour a couple of years ago when I switched from > using gcc 4.0.2 to gcc 4.3.0 to compile some out-of-tree KLD modules. > The problem ended up being a change in the linker script used by GNU > ld for linking kernel modules. It used to always put some magic > symbols used by the linker to implement things like sysinits into the > module. It was changed to only provide those symbols, which > apparently means that the linker would discard those symbols if > nothing referenced them(and nothing did reference them). I had to > work around it by adding the following to my link line: >=20 > -u __start_set_sysinit_set -u __start_set_sysuninit_set \ > -u __start_set_sysctl_set -u __start_set_modmetadata_set \ > -u __stop_set_sysinit_set -u __stop_set_sysuninit_set \ > -u __stop_set_sysctl_set -u __stop_set_modmetadata_set HPS: I added those lines to the LDFLAGS in Makefile.kmod in the cuse4bsd port made the module and the result loads and creates the /dev/cuse file. Here's a diff relative to /usr/ports/multimedia/cuse4bsd-kmod/work/cuse4bsd-kmod-0.1.11 just so it's clear what I did. --- Makefile.kmod.orig 2010-02-11 03:28:02.000000000 -0800 +++ Makefile.kmod 2010-06-22 14:02:52.000000000 -0700 @@ -30,4 +30,10 @@ KMOD=3D cuse4bsd SRCS=3D cuse4bsd_kmod.c device_if.h bus_if.h vnode_if.h =20 +LDFLAGS +=3D -u __start_set_sysinit_set -u __start_set_sysuninit_set \ + -u __start_set_sysctl_set -u __start_set_modmetadata_set \ + -u __stop_set_sysinit_set -u __stop_set_sysuninit_set \ + -u __stop_set_sysctl_set -u __stop_set_modmetadata_set + + .include Running nm -o on the two modules, the difference seems to be that the -u results in some additional absolute symbols being defined: Bad module: $ nm -o /boot/modules/cuse4bsd.ko| grep sys /boot/modules/cuse4bsd.ko:0000275c r __set_sysinit_set_sym_cuse_kern_init_sys_init /boot/modules/cuse4bsd.ko:00002758 r __set_sysuninit_set_sym_cuse_kern_unin= it_sys_uninit /boot/modules/cuse4bsd.ko:00003194 d cuse_kern_init_sys_init /boot/modules/cuse4bsd.ko:00003184 d cuse_kern_uninit_sys_uninit Good module: $ nm -o ./cuse4bsd.ko | grep sys =2E/cuse4bsd.ko:000028cc r __set_sysinit_set_sym_cuse_kern_init_sys_init =2E/cuse4bsd.ko:000028c8 r __set_sysuninit_set_sym_cuse_kern_uninit_sys_uni= nit =2E/cuse4bsd.ko: U __start_set_sysctl_set =2E/cuse4bsd.ko:000028cc A __start_set_sysinit_set =2E/cuse4bsd.ko:000028c8 A __start_set_sysuninit_set =2E/cuse4bsd.ko: U __stop_set_sysctl_set =2E/cuse4bsd.ko:000028d0 A __stop_set_sysinit_set =2E/cuse4bsd.ko:000028cc A __stop_set_sysuninit_set =2E/cuse4bsd.ko:00003194 d cuse_kern_init_sys_init =2E/cuse4bsd.ko:00003184 d cuse_kern_uninit_sys_uninit --=20 Ted Faber http://www.isi.edu/~faber PGP: http://www.isi.edu/~faber/pubkeys.= asc Unexpected attachment on this mail? See http://www.isi.edu/~faber/FAQ.html#= SIG --c3bfwLpm8qysLVxt Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.14 (FreeBSD) iEYEARECAAYFAkwhJgkACgkQaUz3f+Zf+XsIHQCg01pjgmyQMtRhCxX5Vcecfmh6 oAEAoMjEQJnq4qzA5nrwpptyHFNnnJ+T =tM4z -----END PGP SIGNATURE----- --c3bfwLpm8qysLVxt--