Subject: Re: port-mips/22754: mips ld.elf_so picks weak alias over strong alias
To: None <he@netbsd.org>
From: Simon Burge <simonb@wasabisystems.com>
List: netbsd-bugs
Date: 09/12/2003 20:41:22
he@netbsd.org wrote:

> >Number:         22754
> >Category:       port-mips
> >Synopsis:       mips ld.elf_so picks weak alias over strong alias

The problem affects the simplest program linked with -lpthread:

	rhone 88> cat helloworld.c
	main()
	{
		printf("Hello world!\n");
		exit(0);
	}
	rhone 89> cc -o helloworld helloworld.c -lpthread
	rhone 90> ./helloworld
	Abort (core dumped)
	Exit 134
	rhone 91> cc -o helloworld helloworld.c
	rhone 92> ./helloworld
	Hello world!

I'm not really concentrating (watching footy on teevee), but the
following is confusing me at a glance:

	(gdb) run
	Starting program: /tmp/./helloworld 
	Breakpoint 1, __start (sp=2147477272, cleanup=0, obj=0x0, ps_strings=0x0)
	    at /NetBSD/src-virgin/lib/csu/mips/crt0.c:93
	93              ksp = (char**)sp;
	(gdb) step
	66      {
	(gdb) 
	94              if (ksp == 0) {
	(gdb) 
	116             argc = *(int *)ksp;
	(gdb) 
	118             environ = ksp + 2 + argc;       /* 2: argc + NULL ending argv */
	(gdb) 
	120             if ((namep = argv[0]) != NULL) {        /* NULL ptr if argc = 0 */
	(gdb) 
	121                     if ((__progname = _strrchr(namep, '/')) == NULL)
	(gdb) 
	0x4008b0 in _start ()
	    at /home/source/netbsd/src/lib/csu/mips/../common_elf/crti.c:56
	56              INIT_FALLTHRU();
	(gdb) 
	0x30114014 in atexit (func=0x459c <_rtld_exit>)
	    at /home/source/netbsd/src/lib/libc/stdlib/atexit.c:95
	95      
	(gdb) 

	Program received signal SIGABRT, Aborted.
	0x30075404 in kill () at /home/source/netbsd/src/lib/libc/yp/yp_all.c:57
	57              struct ypall_callback *incallback;
	(gdb) bt
	#0  0x30075404 in kill () at /home/source/netbsd/src/lib/libc/yp/yp_all.c:57
	#1  0x30079008 in __libc_mutex_catchall_stub (m=0x2013)
	    at /home/source/netbsd/src/lib/libc/thread-stub/thread-stub.c:97
	#2  0x30113c80 in __cxa_atexit (func=0x459c <_rtld_exit>, arg=0x0, dso=0x0)
	    at /home/source/netbsd/src/lib/libc/stdlib/atexit.c:95
	#3  0x30114034 in atexit (func=0x2013 <_procedure_table+8210>)
	    at /home/source/netbsd/src/lib/libc/stdlib/atexit.c:95
	#4  0x400a00 in _rtld_setup (cleanup=0x459c <_rtld_exit>, obj=0x30003000)
	    at /home/source/netbsd/src/lib/csu/mips/../common_elf/common.c:74
	#5  0x400830 in __start (sp=2147477272, cleanup=0x459c <_rtld_exit>, 
	    obj=0x30003000, ps_strings=0x7fffeff0)
	    at /home/source/netbsd/src/lib/csu/mips/crt0.c:141
	#6  0x2650 in rtld_start ()
	#7  0x2650 in rtld_start ()
	#8  0x2650 in rtld_start ()
	...

Simon.
--
Simon Burge                            <simonb@wasabisystems.com>
NetBSD Support and Service:         http://www.wasabisystems.com/