DragonFly BSD
DragonFly submit List (threaded) for 2004-04
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

libmap and linuxpluginwrapper


From: Rahul Siddharthan <rsidd@xxxxxxxxx>
Date: Mon, 5 Apr 2004 23:36:46 -0400

The linuxpluginwrapper port on FreeBSD-4 and DragonFly requires
changes to rtld-elf and configuring /etc/libmap.conf .  This works
fine for me on DragonFly (I tested the flash plugin on mozilla-firefox
and konqueror).  Is there any reason not to apply this patch to the
base system?

Adapted from http://people.FreeBSD.org/~nork/libmap_4stable.diff

- Rahul
Index: Makefile
===================================================================
RCS file: /home/dcvs/src/libexec/rtld-elf/Makefile,v
retrieving revision 1.4
diff -u -r1.4 Makefile
--- Makefile	20 Jan 2004 21:32:46 -0000	1.4
+++ Makefile	5 Apr 2004 06:15:18 -0000
@@ -3,7 +3,7 @@
 
 PROG=		ld-elf.so.1
 SRCS=		rtld_start.S rtld.c lockdflt.c map_object.c malloc.c \
-		xmalloc.c debug.c reloc.c
+		xmalloc.c debug.c reloc.c libmap.c
 MAN=		rtld.1
 CFLAGS+=	-Wall -DFREEBSD_ELF -I${.CURDIR}/${MACHINE_ARCH} -I${.CURDIR}
 LDFLAGS+=	-nostdlib -e .rtld_start
Index: rtld.1
===================================================================
RCS file: /home/dcvs/src/libexec/rtld-elf/rtld.1,v
retrieving revision 1.2
diff -u -r1.2 rtld.1
--- rtld.1	17 Jun 2003 04:27:08 -0000	1.2
+++ rtld.1	5 Apr 2004 06:15:18 -0000
@@ -89,6 +89,9 @@
 other shared libraries.
 If the directory is not specified then
 the directories specified by
+.It Ev LD_LIBMAP_DISABLE
+If set, disables the use of
+.Xr libmap.conf 5 .
 .Ev LD_LIBRARY_PATH
 will be searched first
 followed by the set of built-in standard directories.
@@ -148,9 +151,12 @@
 .Sh FILES
 .Bl -tag -width indent
 .It Pa /var/run/ld-elf.so.hints
+.It Pa /etc/libmap.conf
+The libmap configuration file.
 .El
 .Sh SEE ALSO
 .Xr ld 1 ,
 .Xr ldd 1 ,
 .Xr elf 5 ,
+.Xr libmap.conf 5 ,
 .Xr ldconfig 8
Index: rtld.c
===================================================================
RCS file: /home/dcvs/src/libexec/rtld-elf/rtld.c,v
retrieving revision 1.7
diff -u -r1.7 rtld.c
--- rtld.c	20 Jan 2004 21:32:46 -0000	1.7
+++ rtld.c	5 Apr 2004 06:17:44 -0000
@@ -54,6 +54,7 @@
 
 #include "debug.h"
 #include "rtld.h"
+#include "libmap.h"
 
 #define END_SYM		"_end"
 #define PATH_RTLD	"/usr/libexec/ld-elf.so.1"
@@ -134,6 +135,7 @@
  */
 static char *error_message;	/* Message for dlerror(), or NULL */
 struct r_debug r_debug;		/* for GDB; */
+static bool libmap_disable;	/* Disable libmap */
 static bool trust;		/* False for setuid and setgid programs */
 static const char *ld_bind_now;	/* Environment variable for immediate binding */
 static const char *ld_debug;	/* Environment variable for debugging */
@@ -308,6 +310,7 @@
     ld_bind_now = _getenv_ld("LD_BIND_NOW");
     if (trust) {
 	ld_debug = _getenv_ld("LD_DEBUG");
+	libmap_disable= _getenv_ld("LD_LIBMAP_DISABLE") != NULL;
 	ld_library_path = _getenv_ld("LD_LIBRARY_PATH");
 	ld_preload = (char *)_getenv_ld("LD_PRELOAD");
     }
@@ -390,6 +393,9 @@
     sym_zero.st_info = ELF_ST_INFO(STB_GLOBAL, STT_NOTYPE);
     sym_zero.st_shndx = SHN_ABS;
 
+    if (!libmap_disable)
+	libmap_disable = (bool)lm_init();
+
     dbg("loading LD_PRELOAD libraries");
     if (load_preload_objects() == -1)
 	die();
@@ -844,19 +850,24 @@
  *   /usr/lib
  */
 static char *
-find_library(const char *name, const Obj_Entry *refobj)
+find_library(const char *xname, const Obj_Entry *refobj)
 {
     char *pathname;
+    char *name;
 
-    if (strchr(name, '/') != NULL) {	/* Hard coded pathname */
-	if (name[0] != '/' && !trust) {
+    if (strchr(xname, '/') != NULL) {	/* Hard coded pathname */
+	if (xname[0] != '/' && !trust) {
 	    _rtld_error("Absolute pathname required for shared object \"%s\"",
-	      name);
+	      xname);
 	    return NULL;
 	}
-	return xstrdup(name);
+	return xstrdup(xname);
     }
 
+    if (libmap_disable || (refobj == NULL) ||
+		(name = lm_find(refobj->path, xname)) == NULL)
+	name = (char *)xname;
+
     dbg(" Searching for \"%s\"", name);
 
     if ((pathname = search_library_path(name, ld_library_path)) != NULL ||
@@ -1486,6 +1497,8 @@
 	obj->refcount = 0;
     objlist_call_fini(&list_fini);
     /* No need to remove the items from the list, since we are exiting. */
+    if (!libmap_disable)
+	lm_fini();
 }
 
 static void *


[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]