Date: 25 Jul 2001 01:21:18 -0500 From: Hal Snyder <hal@vailsys.com> To: freebsd-hackers@freebsd.org Subject: libc.a(err.o) Message-ID: <87d76pmsv5.fsf_-_@gamera.vail> In-Reply-To: <20010725002838.J72882@sneakerz.org> (Alfred Perlstein's message of "Wed, 25 Jul 2001 00:28:39 -0500")
index | next in thread | previous in thread | raw e-mail
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 <stdio.h>
#include <unistd.h>
#include <pwd.h>
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
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?87d76pmsv5.fsf_-_>
