Re: libthr on current breaks some ports

From: Kostik Belousov <kostikbel_at_gmail.com>
Date: Fri, 27 Nov 2009 19:53:17 +0200
On Fri, Nov 27, 2009 at 08:36:36AM -0800, Manfred Antar wrote:
> At 02:40 AM 11/27/2009, Dag-Erling Sm??rgrav wrote:
> >Manfred Antar <null_at_pozo.com> writes:
> >> The new addition to Makefile on /lib/libthr  "-Wl,-znodlopen "
> >> Breaks php4 and mhash on my current 1386
> >
> >If they try to dlopen() libthr, they're already broken.
> >
> >> I'm sure other ports that use it are broken too as can't load the lib.
> >
> >I doubt it.
> >
> >DES
> >-- 
> >Dag-Erling Sm??rgrav - des_at_des.no
> >
> >-- 
> >This message has been scanned for viruses and
> >dangerous content by MailScanner, and is
> >believed to be clean.
> 
> OK
> Here are some of the errors I get
> Just rebuild /usr/ports/graphics/gd
> 
> ldd /usr/local/lib/libgd.so.4
> /usr/local/lib/libgd.so.4: /libexec/ld-elf.so.1: /usr/local/lib/libgd.so.4: Unexpected inconsistency: dependency libthr.so.3 not found
> /usr/local/lib/libgd.so.4: exit status 1
> 
> Just rebuild /usr/ports/security/mhash
> ldd /usr/local/lib/libmhash.so
> /usr/local/lib/libmhash.so: /libexec/ld-elf.so.1: /usr/local/lib/libmhash.so: Unexpected inconsistency: dependency libthr.so.3 not found
> /usr/local/lib/libmhash.so: exit status 1
> 
> Both of these have "--with-LDFLAGS="${PTHREAD_LIBS}" in the Makefile.
> 

This is a real regression, but limited to ldd/LD_TRACE_LOADED_OBJECTS
functionality. The following quick fix worked for me.

diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c
index 320aa85..508a786 100644
--- a/libexec/rtld-elf/rtld.c
+++ b/libexec/rtld-elf/rtld.c
_at__at_ -1571,7 +1571,8 _at__at_ do_load_object(int fd, const char *name, char *path, struct stat *sbp,
     object_add_name(obj, name);
     obj->path = path;
     digest_dynamic(obj, 0);
-    if (obj->z_noopen && (flags & RTLD_LO_DLOPEN)) {
+    if (obj->z_noopen && (flags & (RTLD_LO_DLOPEN | RTLD_LO_TRACE)) ==
+      RTLD_LO_DLOPEN) {
 	dbg("refusing to load non-loadable \"%s\"", obj->path);
 	_rtld_error("Cannot dlopen non-loadable %s\n", obj->path);
 	munmap(obj->mapbase, obj->mapsize);
_at__at_ -2006,6 +2007,8 _at__at_ dlopen(const char *name, int mode)
     lo_flags = RTLD_LO_DLOPEN;
     if (mode & RTLD_NOLOAD)
 	    lo_flags |= RTLD_LO_NOLOAD;
+    if (ld_tracing != NULL)
+	    lo_flags |= RTLD_LO_TRACE;
 
     objlist_init(&initlist);
 
diff --git a/libexec/rtld-elf/rtld.h b/libexec/rtld-elf/rtld.h
index 6f51d7d..875e84b 100644
--- a/libexec/rtld-elf/rtld.h
+++ b/libexec/rtld-elf/rtld.h
_at__at_ -242,8 +242,9 _at__at_ typedef struct Struct_Obj_Entry {
 				   dlsym. */
 
 /* Flags for load_object(). */
-#define	RTLD_LO_NOLOAD	0x01	/* dlopen() specified RTLD_NOLOAD */
-#define	RTLD_LO_DLOPEN	0x02	/* load_object() called from dlopen(). */
+#define	RTLD_LO_NOLOAD	0x01	/* dlopen() specified RTLD_NOLOAD. */
+#define	RTLD_LO_DLOPEN	0x02	/* Load_object() called from dlopen(). */
+#define	RTLD_LO_TRACE	0x04	/* Only tracing. */
 
 /*
  * Symbol cache entry used during relocation to avoid multiple lookups

Received on Fri Nov 27 2009 - 16:53:23 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:58 UTC