bin/189911: [patch] LD_LIBMAP has no effect on rtld

Wolfgang Jenkner wjenkner at inode.at
Sun May 18 14:10:01 UTC 2014


>Number:         189911
>Category:       bin
>Synopsis:       [patch] LD_LIBMAP has no effect on rtld
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun May 18 14:10:00 UTC 2014
>Closed-Date:
>Last-Modified:
>Originator:     Wolfgang Jenkner
>Release:        FreeBSD 10.0-STABLE amd64
>Organization:
>Environment:
System: FreeBSD iznogoud.viz 10.0-STABLE FreeBSD 10.0-STABLE #0 r265095M: Tue Apr 29 20:38:44 CEST 2014 adm at iznogoud.viz:/usr/obj/usr/src/sys/IZNOGOUD-drm-update-38.a+ amd64

>Description:
Mapping a shared library to another - existing or not existing - library
via LD_LIBMAP, as described in rtld(1), has no effect (but it does work
when done in libmap.conf).
>How-To-Repeat:
$ LD_LIBMAP=libncurses.so.8=libncurses.so.5 ldd /bin/ls
/bin/ls:
	libutil.so.9 => /lib/libutil.so.9 (0x800823000)
	libncurses.so.8 => /lib/libncurses.so.8 (0x800a35000)
	libc.so.7 => /lib/libc.so.7 (0x800c82000)

On the other hand, with

$ cat /etc/libmap.conf
[ls]
libncurses.so.8 libncurses.so.5
$ 

we get

$ ldd /bin/ls
/bin/ls:
	libutil.so.9 => /lib/libutil.so.9 (0x800823000)
	libncurses.so.8 => /usr/local/lib/libncurses.so.5 (0x800a35000)
	libc.so.7 => /lib/libc.so.7 (0x800c53000)
	libtinfo.so.5.9 => /usr/local/lib/libtinfo.so.5.9 (0x800ffa000)
$ 

if  libncurses.so.5 from the devel/ncurses port exists.

Otherwise, we get

$ ldd /bin/ls
/bin/ls:
	libutil.so.9 => /lib/libutil.so.9 (0x800823000)
	libncurses.so.8 => not found (0)
	libc.so.7 => /lib/libc.so.7 (0x800a35000)
$ 

>Fix:
The following patch is against 10-STABLE, but should apply to HEAD as
well.

It seems that, due to an oversight in HEAD r232862, lmc_parse() was
passed wrong arguments in the libmap_override case.

Index: libexec/rtld-elf/libmap.c
===================================================================
--- libexec/rtld-elf/libmap.c	(revision 265095)
+++ libexec/rtld-elf/libmap.c	(working copy)
@@ -80,7 +80,7 @@
 
 	if (libmap_override) {
 		/*
-		 * Do some character replacement to make $LIBMAP look
+		 * Do some character replacement to make $LD_LIBMAP look
 		 * like a text file, then parse it.
 		 */
 		libmap_override = xstrdup(libmap_override);
@@ -94,8 +94,8 @@
 				break;
 			}
 		}
-		lmc_parse(p, strlen(p));
-		free(p);
+		lmc_parse(libmap_override, p - libmap_override);
+		free(libmap_override);
 	}
 
 	return (lm_count == 0);
>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list