From owner-freebsd-hackers Tue Jul 24 23:21:51 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from area51.vail (chrobd01.vailsys.com [63.210.102.138]) by hub.freebsd.org (Postfix) with ESMTP id 010FA37B401 for ; Tue, 24 Jul 2001 23:21:41 -0700 (PDT) (envelope-from hal@vailsys.com) Received: from gamera.vail (root@gamera.vail [172.16.15.1]) by area51.vail (8.9.3/8.9.3) with ESMTP id BAA52829 for ; Wed, 25 Jul 2001 01:21:19 -0500 (CDT) (envelope-from hal@vailsys.com) Received: (from hal@localhost) by gamera.vail (8.11.4/8.11.3) id f6P6LIN02606; Wed, 25 Jul 2001 01:21:18 -0500 (CDT) X-Authentication-Warning: gamera.vail: hal set sender to hal@vailsys.com using -f To: freebsd-hackers@freebsd.org Subject: libc.a(err.o) From: Hal Snyder Date: 25 Jul 2001 01:21:18 -0500 In-Reply-To: <20010725002838.J72882@sneakerz.org> (Alfred Perlstein's message of "Wed, 25 Jul 2001 00:28:39 -0500") Message-ID: <87d76pmsv5.fsf_-_@gamera.vail> Lines: 89 User-Agent: Gnus/5.090004 (Oort Gnus v0.04) XEmacs/21.1 (Cuyahoga Valley) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG I am wondering if there is a problem with err, warn, etc. in libc. All these functions are in the same module, err.o. If you redefine some of the err.o functions, and call a libc function that depends on another (not redefined) one of the functions, then link statically, you end up with a multiply-defined symbol. I ran into this building a cvs snap of sfs (www.fs.net) on FreeBSD-current. Have reviewed it with the author of that package, who contributed the code snippet below. A toy example of the problem follows using endpwent(). Note endpwent() indirectly depends on err.o: Archive member included because of file (symbol) ... /usr/lib/libc.a(err.o) /usr/lib/libc.a(stringlist.o) (err) /usr/lib/libc.a(stringlist.o) /usr/lib/libc.a(getusershell.o) (sl_add) /usr/lib/libc.a(getusershell.o) /usr/lib/libc.a(pw_scan.o) (getusershell) /usr/lib/libc.a(pw_scan.o) /usr/lib/libc.a(getpwent.o) (__pw_scan) /usr/lib/libc.a(getpwent.o) ../sfsmisc/.libs/libsfsmisc.a(sfsconst.o) (endpwent) Here is the code: #include #include #include void warn (const char *msg) { fprintf (stderr, "WARNING: %s\n", msg); } int main (int argc, char **argv) { endpwent (); warn ("exiting"); return 0; } Static linking produces the following: >cc -Wl,-Bstatic -o dms dm.c /usr/lib/libc.a(err.o): In function `warn': err.o(.text+0x1e0): multiple definition of `warn' /tmp/cchk0Ydc.o(.text+0x0): first defined here /usr/libexec/elf/ld: Warning: size of symbol `warn' changed from 33 to 30 in err.o Bug? Feature? Do we want separate modules? Weak symbols? Note on FreeBSD we have /usr/lib/libc.a:err.o:00000030 T err /usr/lib/libc.a:err.o:00000020 T err_set_exit /usr/lib/libc.a:err.o:00000000 T err_set_file /usr/lib/libc.a:err.o:00000070 T errc /usr/lib/libc.a:err.o:00000138 T errx /usr/lib/libc.a:err.o:00000050 T verr /usr/lib/libc.a:err.o:00000088 T verrc /usr/lib/libc.a:err.o:00000150 T verrx /usr/lib/libc.a:err.o:00000200 T vwarn /usr/lib/libc.a:err.o:0000023c T vwarnc /usr/lib/libc.a:err.o:000002e0 T vwarnx /usr/lib/libc.a:err.o:000001e0 T warn /usr/lib/libc.a:err.o:00000220 T warnc /usr/lib/libc.a:err.o:000002c8 T warnx while NetBSD has /usr/lib/libc.a:warn.o:00000000 T _warn /usr/lib/libc.a:warn.o:00000000 W warn /usr/lib/libc.a:vwarn.o:00000000 T _vwarn /usr/lib/libc.a:vwarn.o:00000000 W vwarn /usr/lib/libc.a:warnx.o:00000000 T _warnx /usr/lib/libc.a:warnx.o:00000000 W warnx /usr/lib/libc.a:vwarnx.o:00000000 T _vwarnx /usr/lib/libc.a:vwarnx.o:00000000 W vwarnx To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message