Subject: Re: port-amd64/30570: dlopen(..., RTLD_NOW) always returns non-null
To: None <port-amd64-maintainer@netbsd.org, gnats-admin@netbsd.org,>
From: Christos Zoulas <christos@zoulas.com>
List: netbsd-bugs
Date: 06/21/2005 04:24:02
The following reply was made to PR port-amd64/30570; it has been noted by GNATS.

From: christos@zoulas.com (Christos Zoulas)
To: gnats-bugs@netbsd.org, port-amd64-maintainer@netbsd.org,
	gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Cc: 
Subject: Re: port-amd64/30570: dlopen(..., RTLD_NOW) always returns non-null
Date: Tue, 21 Jun 2005 00:22:57 -0400

 On Jun 21,  4:16am, jlam@NetBSD.org (jlam@NetBSD.org) wrote:
 -- Subject: port-amd64/30570: dlopen(..., RTLD_NOW) always returns non-null
 
 | >Number:         30570
 | >Category:       port-amd64
 | >Synopsis:       dlopen(..., RTLD_NOW) always returns non-null
 | >Confidential:   no
 | >Severity:       serious
 | >Priority:       high
 | >Responsible:    port-amd64-maintainer
 | >State:          open
 | >Class:          sw-bug
 | >Submitter-Id:   net
 | >Arrival-Date:   Tue Jun 21 04:16:00 +0000 2005
 | >Originator:     Johnny C. Lam
 | >Release:        NetBSD 2.0_STABLE
 | >Organization:
 | 	The NetBSD Project
 | >Environment:
 | System: NetBSD er2.home.local 2.0_STABLE NetBSD 2.0_STABLE (ERACKS) #0: Mon Jan 3 00:12:46 EST 2005 jlam@er2.home.local:/local/sources/cvs.netbsd.org/netbsd-2/amd64/obj/sys/arch/amd64/compile/ERACKS amd64
 | Architecture: x86_64
 | Machine: amd64
 | >Description:
 | 	dlopen(..., RTLD_NOW) returns non-null, even if the shared module
 | 	it is asked to open contains unresolved symbols.
 | 
 | >How-To-Repeat:
 | 	The following is the exact test case used by the configure script
 | 	in pkgsrc/chat/ircservices:
 | 
 | 	% cat test-dlopen.c
 | 	#include <dlfcn.h>
 | 	int main(int argc, char **argv) {
 | 		void *lib = dlopen("./test-lib.so", RTLD_NOW);
 | 		printf("%d\n", lib != 0);
 | 		if (lib)
 | 			dlclose(lib);
 | 		return 0;
 | 	}
 | 
 | 	% cat test-lib.c
 | 	int foo() {no_such_symbol();}
 | 
 | 	% cc -fPIC test-dlopen.c -o test-dlopen
 | 	% cc -shared -fPIC test-lib.c -o test-lib.so
 | 	% ./test-dlopen
 | 	1
 | 
 | 	I expected the "test-dlopen" program to print "0", as it did on
 | 	the NetBSD-1.6.2/i386 system I also tested this on.
 | 
 
 Does this fix your problem?
 
 christos
 
 Index: reloc.c
 ===================================================================
 RCS file: /cvsroot/src/libexec/ld.elf_so/reloc.c,v
 retrieving revision 1.89
 diff -u -u -r1.89 reloc.c
 --- reloc.c	31 May 2005 19:30:38 -0000	1.89
 +++ reloc.c	21 Jun 2005 04:22:32 -0000
 @@ -192,7 +192,7 @@
  #endif
  #if defined(__i386__) || defined(__arm__) || defined(__hppa__) \
      || defined(__sparc64__) || defined(__sparc__) || defined(__alpha__) \
 -    || defined(__sh3__)
 +    || defined(__sh3__) || defined(__x86_64__)
  		if (bind_now) {
  			dbg(("doing immediate PLT binding"));
  			if (_rtld_relocate_plt_objects(obj) < 0)