Subject: Linker bug of the day?
To: None <port-mips@netbsd.org>
From: Simon Burge <simonb@netbsd.org>
List: port-mips
Date: 04/27/1999 14:53:51
Trying to test a nsswitch change on my 1.4 pmax, I get the following
(I've indented the output of each command so it's a tad easier to read):

	mona:/var/tmp 237> cat foo.c
		#include <grp.h>

		main()
		{
			struct group *gr;

			gr = getgrnam("wheel");
			printf("%p\n", gr);
			exit(0);
		}
	mona:/var/tmp 238> cc -o foo foo.c
	mona:/var/tmp 239> time ./foo
		0x200f18c8
		0.011u 0.037s 0:00.04 100.0%    0+0k 0+0io 2pf+0w
	mona:/var/tmp 240> cc -static -o foo foo.c
	mona:/var/tmp 241> time ./foo
		0x100011d8
		0.007u 0.023s 0:00.02 100.0%    0+0k 0+1io 21pf+0w
	mona:/var/tmp 242> cc -static -o foo foo.c /usr/lib/libc.a
	mona:/var/tmp 243> time ./foo
		0x100011d8
		0.003u 0.027s 0:00.02 100.0%    0+0k 0+0io 21pf+0w
	mona:/var/tmp 244> cc -o foo foo.c /usr/lib/libc.a
		/usr/lib/libc.so: warning: this program uses xdr_domainname(), which is deprecated and buggy.
		/usr/lib/libc.so: warning: this program uses xdr_mapname(), which is deprecated and buggy.
		/usr/lib/libc.so: warning: this program uses xdr_peername(), which is deprecated and buggy.
	mona:/var/tmp 245> time ./foo
		^C0.018u 0.033s 0:11.20 0.3%    0+0k 0+0io 16pf+0w
	mona:/var/tmp 246> gdb ./foo
		GNU gdb 4.17
		Copyright 1998 Free Software Foundation, Inc.
		GDB is free software, covered by the GNU General Public License, and you are
		welcome to change it and/or distribute copies of it under certain conditions.
		Type "show copying" to see the conditions.
		There is absolutely no warranty for GDB.  Type "show warranty" for details.
		This GDB was configured as "mipsel--netbsd"...
		(gdb) run
		Starting program: /var/tmp/./foo 
		^C
		Program received signal SIGINT, Interrupt.
		0x426dd4 in read () at read:2
		read:2: No such file or directory.
		(gdb) bt
		#0  0x426dd4 in read () at read:2
		#1  0x426a28 in __sread ()
		#2  0x41decc in __srefill ()
		#3  0x41dc94 in __srget ()
		#4  0x41d95c in getc ()
		#5  0x2007f370 in yy_get_next_buffer ()
		#6  0x2007eee4 in _nsyylex ()
		#7  0x4283fc in _nsyyparse ()
		#8  0x41937c in _nsdbtget ()
		#9  0x4196c0 in nsdispatch ()
		#10 0x40552c in grscan ()
		#11 0x404240 in getgrnam ()
		#12 0x403ff0 in main ()
		(gdb) quit
		The program is running.  Exit anyway? (y or n) y
	mona:/var/tmp 247> cc -o foo foo.c /usr/lib/libc.so
	mona:/var/tmp 248> time ./foo
		0x200f18c8
		0.019u 0.027s 0:00.04 75.0%     0+0k 0+1io 2pf+0w
	mona:/var/tmp 249> 

Also:

	mona:/var/tmp 310> cc -o foo foo.c /usr/lib/libc.a
		/usr/lib/libc.so: warning: this program uses xdr_domainname(), which is deprecated and buggy.
		/usr/lib/libc.so: warning: this program uses xdr_mapname(), which is deprecated and buggy.
		/usr/lib/libc.so: warning: this program uses xdr_peername(), which is deprecated and buggy.
	mona:/var/tmp 311> fg
		priv tcsh (wd: ~)
	mona:/var/tmp 100# rm -f /etc/nsswitch.conf
	mona:/var/tmp 101# ./foo
		0x100013f8
	mona:/var/tmp 102# touch /etc/nsswitch.conf
	mona:/var/tmp 103# ./foo
		^C
	mona:/var/tmp 104# 

If I do a getpwnam("root") instead, I still get the xdr* warnings but
the program runs fine.  I also tested this on an i386, and each case
worked ok.

I'm not even going to begin to try and wrap my brain around what's
happening here...

Simon.