svn commit: r263031 - in stable/9: . etc etc/mtree libexec/rtld-elf share/man/man5 share/mk
Dag-Erling Smørgrav
des at FreeBSD.org
Tue Mar 11 16:13:06 UTC 2014
Author: des
Date: Tue Mar 11 16:13:03 2014
New Revision: 263031
URL: http://svnweb.freebsd.org/changeset/base/263031
Log:
MFH (r251810): fix installation from read-only .OBJDIR
MFH (r255384): add PRIVATELIB for internal-use shred libraries
MFH (r255385, r255413): add a stock libmap32.conf
MFH (r255765): always support directory mapping; rewrite libmap man page
Added:
stable/9/etc/libmap32.conf
- copied unchanged from r255413, head/etc/libmap32.conf
Modified:
stable/9/Makefile.inc1 (contents, props changed)
stable/9/etc/Makefile
stable/9/etc/mtree/BSD.usr.dist
stable/9/libexec/rtld-elf/libmap.c
stable/9/libexec/rtld-elf/libmap.h
stable/9/libexec/rtld-elf/rtld.c
stable/9/share/man/man5/libmap.conf.5
stable/9/share/mk/bsd.lib.mk
stable/9/share/mk/bsd.own.mk
stable/9/share/mk/bsd.prog.mk
Directory Properties:
stable/9/ (props changed)
stable/9/etc/ (props changed)
stable/9/etc/mtree/ (props changed)
stable/9/libexec/rtld-elf/ (props changed)
stable/9/share/ (props changed)
stable/9/share/man/ (props changed)
stable/9/share/man/man5/ (props changed)
stable/9/share/mk/ (props changed)
Modified: stable/9/Makefile.inc1
==============================================================================
--- stable/9/Makefile.inc1 Tue Mar 11 15:46:03 2014 (r263030)
+++ stable/9/Makefile.inc1 Tue Mar 11 16:13:03 2014 (r263031)
@@ -332,6 +332,7 @@ LIB32WMAKEENV+= MAKEOBJDIRPREFIX=${OBJTR
PATH=${TMPPATH} \
LIBDIR=/usr/lib32 \
SHLIBDIR=/usr/lib32 \
+ LIBPRIVATEDIR=/usr/lib32/private \
COMPILER_TYPE=${WMAKE_COMPILER_TYPE}
LIB32WMAKEFLAGS+= \
CC="${CC} ${LIB32FLAGS}" \
Modified: stable/9/etc/Makefile
==============================================================================
--- stable/9/etc/Makefile Tue Mar 11 15:46:03 2014 (r263030)
+++ stable/9/etc/Makefile Tue Mar 11 16:13:03 2014 (r263031)
@@ -50,6 +50,10 @@ BIN1= crontab \
syslog.conf \
termcap.small
+.if ${TARGET_ARCH} == "amd64" || ${TARGET_ARCH} == "powerpc64"
+BIN1+= libmap32.conf
+.endif
+
.if exists(${.CURDIR}/etc.${MACHINE}/ttys)
BIN1+= etc.${MACHINE}/ttys
.elif exists(${.CURDIR}/etc.${MACHINE_ARCH}/ttys)
Copied: stable/9/etc/libmap32.conf (from r255413, head/etc/libmap32.conf)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ stable/9/etc/libmap32.conf Tue Mar 11 16:13:03 2014 (r263031, copy of r255413, head/etc/libmap32.conf)
@@ -0,0 +1,2 @@
+# $FreeBSD$
+/usr/lib/private /usr/lib32/private
Modified: stable/9/etc/mtree/BSD.usr.dist
==============================================================================
--- stable/9/etc/mtree/BSD.usr.dist Tue Mar 11 15:46:03 2014 (r263030)
+++ stable/9/etc/mtree/BSD.usr.dist Tue Mar 11 16:13:03 2014 (r263031)
@@ -24,12 +24,16 @@
..
i18n
..
+ private
+ ..
..
lib32
dtrace
..
i18n
..
+ private
+ ..
..
libdata
gcc
Modified: stable/9/libexec/rtld-elf/libmap.c
==============================================================================
--- stable/9/libexec/rtld-elf/libmap.c Tue Mar 11 15:46:03 2014 (r263030)
+++ stable/9/libexec/rtld-elf/libmap.c Tue Mar 11 16:13:03 2014 (r263031)
@@ -396,7 +396,6 @@ lm_find (const char *p, const char *f)
/* Given a libmap translation list and a library name, return the
replacement library, or NULL */
-#ifdef COMPAT_32BIT
char *
lm_findn (const char *p, const char *f, const int n)
{
@@ -413,7 +412,6 @@ lm_findn (const char *p, const char *f,
free(s);
return (t);
}
-#endif
static char *
lml_find (struct lm_list *lmh, const char *f)
Modified: stable/9/libexec/rtld-elf/libmap.h
==============================================================================
--- stable/9/libexec/rtld-elf/libmap.h Tue Mar 11 15:46:03 2014 (r263030)
+++ stable/9/libexec/rtld-elf/libmap.h Tue Mar 11 16:13:03 2014 (r263031)
@@ -5,6 +5,4 @@
int lm_init (char *);
void lm_fini (void);
char * lm_find (const char *, const char *);
-#ifdef COMPAT_32BIT
char * lm_findn (const char *, const char *, const int);
-#endif
Modified: stable/9/libexec/rtld-elf/rtld.c
==============================================================================
--- stable/9/libexec/rtld-elf/rtld.c Tue Mar 11 15:46:03 2014 (r263030)
+++ stable/9/libexec/rtld-elf/rtld.c Tue Mar 11 16:13:03 2014 (r263031)
@@ -2612,12 +2612,14 @@ rtld_exit(void)
lock_release(rtld_bind_lock, &lockstate);
}
+/*
+ * Iterate over a search path, translate each element, and invoke the
+ * callback on the result.
+ */
static void *
path_enumerate(const char *path, path_enum_proc callback, void *arg)
{
-#ifdef COMPAT_32BIT
const char *trans;
-#endif
if (path == NULL)
return (NULL);
@@ -2627,13 +2629,11 @@ path_enumerate(const char *path, path_en
char *res;
len = strcspn(path, ":;");
-#ifdef COMPAT_32BIT
trans = lm_findn(NULL, path, len);
if (trans)
res = callback(trans, strlen(trans), arg);
else
-#endif
- res = callback(path, len, arg);
+ res = callback(path, len, arg);
if (res != NULL)
return (res);
Modified: stable/9/share/man/man5/libmap.conf.5
==============================================================================
--- stable/9/share/man/man5/libmap.conf.5 Tue Mar 11 15:46:03 2014 (r263030)
+++ stable/9/share/man/man5/libmap.conf.5 Tue Mar 11 16:13:03 2014 (r263031)
@@ -1,4 +1,5 @@
.\" Copyright (c) 2003 Matthew N. Dodd <winter at jurai.net>
+.\" Copyright (c) 2013 Dag-Erling Smørgrav
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
@@ -24,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd April 28, 2012
+.Dd September 16, 2013
.Dt LIBMAP.CONF 5
.Os
.Sh NAME
@@ -35,109 +36,105 @@ The
.Nm libmap
functionality of
.Xr ld-elf.so.1 1
-allows dynamic object dependencies to be mapped to arbitrary
-names.
+allows dynamic object dependencies to be mapped to arbitrary names.
.Pp
-The configuration file consists of two whitespace separated columns; the
-left hand side containing the mapping candidate and the right hand
-side containing the mapping.
-Dependencies are matched against candidates and replaced with the mappings.
-.Pp
-Two special directives are available:
+Each line in
+.Pa /etc/libmap.conf
+can have one of five forms:
.Bl -tag -width indent
+.It Ar origin Ar target
+Whenever a dependency on
+.Ar origin
+is encountered while loading a dynamic object, use
+.Ar target
+instead of searching for
+.Ar origin
+in the normal library search paths.
+.It Ar path1 Ar path2
+When iterating through a library search path, replace any element that
+matches
+.Ar path1
+exactly with
+.Ar path2 .
+.It Bq Ar constraint
+Apply
+.Ar constraint
+to all subsequent mappings until the next constraint line or the end
+of the file.
+See the
+.Sx Constraints
+section for details.
.It Cm include Ar file
Parse the contents of
.Ar file
before continuing with the current file.
+Nesting depth is limited only by available memory, but each file
+encountered is processed only once, and loops are silently ignored.
.It Cm includedir Ar dir
-Parse the contents of every file in
+Recurse through
.Ar dir
-that ends in
+and parse the contents of any file that ends in
.Pa .conf
before continuing with the current file.
+Nesting depth is limited only by available memory, but each directory
+or file encountered is processed only once, and loops are silently
+ignored.
.El
-.Pp
-Any file or directory encountered while processing
-.Cm include
-or
-.Cm includedir
-directives will be parsed exactly once, even if it is encountered
-multiple times.
-.Pp
-Constrained mappings may be specified by enclosing the name of the
-executable or library in brackets.
-All mappings following a constraint will only be evaluated for that constraint.
-Constraints can be one of three types:
+.Ss Constraints
+Constrained mappings only apply when processing binaries or libraries
+that satisfy the constraint.
+There are three types of constraints:
.Bl -tag -width indent
.It Exact
The constraint is matched literally so that only an executable with an
-identical fully qualified pathname will match the constraint.
+identical fully qualified pathname will satisfy the constraint.
This means that the executable
.Pa /usr/bin/foo
-will not match a constraint for
-.Pa /usr/bin/./foo
+will not satisfy the constraint
+.Bq Pa /usr/bin/./foo ,
and vice-versa.
This is the default constraint type.
.It Basename
A constraint with no path is matched against the basename of the
executable.
-.Pa foo
+For instance, the constraint
+.Bq Pa foo
will match
.Pa /bin/foo ,
.Pa /usr/local/sbin/foo ,
or any other executable named
.Pa foo ,
-no matter what its path is.
+no matter what directory it is in.
.It Directory
-A constraint with a trailing slash is prefix-matched against the full
-pathname of the executable.
-.Pa /usr/bin/
-will match any executable with a path starting with /usr/bin.
+A constraint with a trailing slash is satisfied if the full pathname
+begins with the constraint string.
+For instance, the constraint
+.Bq Pa /usr/bin/
+will match any executable with a path starting with
+.Pa /usr/bin/ .
.El
.Pp
-Note that the executable path matched against is the
-.Fa path
-parameter in an
-.Fn exec*
-function call.
-The Directory or Exact constraints can only match when the executable
-is called with a full pathname.
+Note that the constraints are matched against the path that was passed
+as the first argument to whichever
+.Xr exec 3
+function was used to execute the binary in question.
Most programs executed from a shell are run without a full path, via
-.Fn exec*p ,
-so the Basename constraint type is the most useful.
+.Xr execvp 3
+or similar, so the basename constraint type is the most useful.
.Pp
+.Bf -symbolic
WARNING!
-Constrained mappings must never appear first in the configuration file.
-While there is a way to specify the
-.Dq default
-constraint, its use is not recommended.
-.Pp
-The most common use at the date of writing is for allowing multiple
-.Tn POSIX
-threading libraries to be used on a system without relinking or
-changing symlinks.
-.Pp
-On 64-bit architectures that provide 32-bit runtime support,
-the libmap mechanism is available for 32-bit binaries too.
-The mappings has to be written into separate configuration file
+Constraints apply to all mappings until the next constraint or the end
+of the file.
+Hence, unconstrained mappings must be placed at the top of the file.
+.Ef
+.Ss ABI compatibility
+On 64-bit architectures that provide 32-bit binary compatibility, the
+mappings in
+.Pa /etc/libmap.conf
+apply only to 64-bit binaries.
+Mappings for 32-bit binaries must be placed in
.Pa /etc/libmap32.conf .
-Currently only supported on amd64.
-.Pp
-This mechanism has also been used to create shims to allow Linux
-shared libraries to be dynamically loaded into
-.Fx
-binaries.
-In this case, an Exact constraint is used for the Linux shared library,
-mapping libraries it depends on to a wrapper.
-The wrapper then defines any needed symbols for the Linux shared library
-and relies on its libraries not being mapped to provide actual
-implementations.
-It appears that only libraries loaded via
-.Xr dlopen 3
-will work correctly.
-The symbol version information in shared libraries is checked at
-link time, but at run time the version information is currently
-ignored.
.Sh FILES
.Bl -tag -width ".Pa /etc/libmap32.conf" -compact
.It Pa /etc/libmap.conf
@@ -147,9 +144,8 @@ The libmap configuration file for 32-bit
.El
.Sh EXAMPLES
.Bd -literal
-# /etc/libmap.conf
#
-# candidate mapping
+# origin target
#
libc_r.so.6 libpthread.so.2 # Everything that uses 'libc_r'
libc_r.so libpthread.so # now uses 'libpthread'
@@ -174,11 +170,11 @@ libdl.so.2 pluginwrapper/pips.so
.Xr rtld 1
.Sh HISTORY
The
-.Nm
-manual page and
.Nm libmap
-functionality first appeared in
+mechanism first appeared in
.Fx 5.1 .
.Sh AUTHORS
This manual page was written by
-.An Matthew N. Dodd Aq winter at jurai.net .
+.An Matthew N. Dodd Aq winter at jurai.net
+and extensively rewritten by
+.An Dag-Erling Sm\(/orgrav Aq des at FreeBSD.org .
Modified: stable/9/share/mk/bsd.lib.mk
==============================================================================
--- stable/9/share/mk/bsd.lib.mk Tue Mar 11 15:46:03 2014 (r263030)
+++ stable/9/share/mk/bsd.lib.mk Tue Mar 11 16:13:03 2014 (r263031)
@@ -119,16 +119,24 @@ PO_FLAG=-pg
all: objwarn
+.if defined(PRIVATELIB)
+_LIBDIR:=${LIBPRIVATEDIR}
+_SHLIBDIR:=${LIBPRIVATEDIR}
+.else
+_LIBDIR:=${LIBDIR}
+_SHLIBDIR:=${SHLIBDIR}
+.endif
+
.if defined(SHLIB_NAME)
.if ${MK_DEBUG_FILES} != "no"
SHLIB_NAME_FULL=${SHLIB_NAME}.full
# Use ${DEBUGDIR} for base system debug files, else .debug subdirectory
-.if ${SHLIBDIR} == "/boot" ||\
+.if ${_SHLIBDIR} == "/boot" ||\
${SHLIBDIR:C%/lib(/.*)?$%/lib%} == "/lib" ||\
${SHLIBDIR:C%/usr/lib(32)?(/.*)?%/usr/lib%} == "/usr/lib"
-DEBUGFILEDIR=${DEBUGDIR}${SHLIBDIR}
+DEBUGFILEDIR=${DEBUGDIR}${_SHLIBDIR}
.else
-DEBUGFILEDIR=${SHLIBDIR}/.debug
+DEBUGFILEDIR=${_SHLIBDIR}/.debug
DEBUGMKDIR=
.endif
.else
@@ -145,6 +153,10 @@ ${SHLIB_NAME_FULL}: ${VERSION_MAP}
LDFLAGS+= -Wl,--version-script=${VERSION_MAP}
.endif
+.if defined(USEPRIVATELIB)
+LDFLAGS+= -L${_SHLIBDIRPREFIX}${LIBPRIVATEDIR} -rpath ${LIBPRIVATEDIR}
+.endif
+
.if defined(LIB) && !empty(LIB) || defined(SHLIB_NAME)
OBJS+= ${SRCS:N*.h:R:S/$/.o/}
.endif
@@ -291,16 +303,16 @@ realinstall: _libinstall
_libinstall:
.if defined(LIB) && !empty(LIB) && ${MK_INSTALLLIB} != "no"
${INSTALL} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
- ${_INSTALLFLAGS} lib${LIB}.a ${DESTDIR}${LIBDIR}
+ ${_INSTALLFLAGS} lib${LIB}.a ${DESTDIR}${_LIBDIR}
.endif
.if ${MK_PROFILE} != "no" && defined(LIB) && !empty(LIB)
${INSTALL} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
- ${_INSTALLFLAGS} lib${LIB}_p.a ${DESTDIR}${LIBDIR}
+ ${_INSTALLFLAGS} lib${LIB}_p.a ${DESTDIR}${_LIBDIR}
.endif
.if defined(SHLIB_NAME)
${INSTALL} ${STRIP} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
${_INSTALLFLAGS} ${_SHLINSTALLFLAGS} \
- ${SHLIB_NAME} ${DESTDIR}${SHLIBDIR}
+ ${SHLIB_NAME} ${DESTDIR}${_SHLIBDIR}
.if ${MK_DEBUG_FILES} != "no"
.if defined(DEBUGMKDIR)
${INSTALL} -T debug -d ${DESTDIR}${DEBUGFILEDIR}
@@ -328,20 +340,23 @@ _libinstall:
# installworld; in the later case ${_LDSCRIPTROOT} must be obviously empty
# because on the target system, libraries are meant to be looked up from /.
.if defined(SHLIB_LDSCRIPT) && !empty(SHLIB_LDSCRIPT) && exists(${.CURDIR}/${SHLIB_LDSCRIPT})
- sed -e 's,@@SHLIB@@,${_LDSCRIPTROOT}${SHLIBDIR}/${SHLIB_NAME},g' \
- -e 's,@@LIBDIR@@,${_LDSCRIPTROOT}${LIBDIR},g' \
- ${.CURDIR}/${SHLIB_LDSCRIPT} > lib${LIB}.ld
+ sed -e 's,@@SHLIB@@,${_LDSCRIPTROOT}${_SHLIBDIR}/${SHLIB_NAME},g' \
+ -e 's,@@LIBDIR@@,${_LDSCRIPTROOT}${_LIBDIR},g' \
+ ${.CURDIR}/${SHLIB_LDSCRIPT} > ${DESTDIR}${_LIBDIR}/${SHLIB_LINK:R}.ld
${INSTALL} -S -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
- ${_INSTALLFLAGS} lib${LIB}.ld ${DESTDIR}${LIBDIR}/${SHLIB_LINK}
+ ${_INSTALLFLAGS} ${DESTDIR}${_LIBDIR}/${SHLIB_LINK:R}.ld \
+ ${DESTDIR}${_LIBDIR}/${SHLIB_LINK}
+ rm -f ${DESTDIR}${_LIBDIR}/${SHLIB_LINK:R}.ld
+
.else
-.if ${SHLIBDIR} == ${LIBDIR}
- ${INSTALL_SYMLINK} ${SHLIB_NAME} ${DESTDIR}${LIBDIR}/${SHLIB_LINK}
+.if ${_SHLIBDIR} == ${_LIBDIR}
+ ${INSTALL_SYMLINK} ${SHLIB_NAME} ${DESTDIR}${_LIBDIR}/${SHLIB_LINK}
.else
- ${INSTALL_SYMLINK} ${_SHLIBDIRPREFIX}${SHLIBDIR}/${SHLIB_NAME} \
- ${DESTDIR}${LIBDIR}/${SHLIB_LINK}
-.if exists(${DESTDIR}${LIBDIR}/${SHLIB_NAME})
- -chflags noschg ${DESTDIR}${LIBDIR}/${SHLIB_NAME}
- rm -f ${DESTDIR}${LIBDIR}/${SHLIB_NAME}
+ ${INSTALL_SYMLINK} ${_SHLIBDIRPREFIX}${_SHLIBDIR}/${SHLIB_NAME} \
+ ${DESTDIR}${_LIBDIR}/${SHLIB_LINK}
+.if exists(${DESTDIR}${_LIBDIR}/${SHLIB_NAME})
+ -chflags noschg ${DESTDIR}${_LIBDIR}/${SHLIB_NAME}
+ rm -f ${DESTDIR}${_LIBDIR}/${SHLIB_NAME}
.endif
.endif
.endif # SHLIB_LDSCRIPT
@@ -349,7 +364,7 @@ _libinstall:
.endif # SHIB_NAME
.if defined(INSTALL_PIC_ARCHIVE) && defined(LIB) && !empty(LIB) && ${MK_TOOLCHAIN} != "no"
${INSTALL} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
- ${_INSTALLFLAGS} lib${LIB}_pic.a ${DESTDIR}${LIBDIR}
+ ${_INSTALLFLAGS} lib${LIB}_pic.a ${DESTDIR}${_LIBDIR}
.endif
.if defined(WANT_LINT) && !defined(NO_LINT) && defined(LIB) && !empty(LIB)
${INSTALL} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
Modified: stable/9/share/mk/bsd.own.mk
==============================================================================
--- stable/9/share/mk/bsd.own.mk Tue Mar 11 15:46:03 2014 (r263030)
+++ stable/9/share/mk/bsd.own.mk Tue Mar 11 16:13:03 2014 (r263031)
@@ -28,6 +28,8 @@
#
# LIBCOMPATDIR Base path for compat libraries. [/usr/lib/compat]
#
+# LIBPRIVATEDIR Base path for private libraries. [/usr/lib/private]
+#
# LIBDATADIR Base path for misc. utility data files. [/usr/libdata]
#
# LIBEXECDIR Base path for system daemons and utilities. [/usr/libexec]
@@ -144,6 +146,7 @@ KMODMODE?= ${BINMODE}
LIBDIR?= /usr/lib
LIBCOMPATDIR?= /usr/lib/compat
+LIBPRIVATEDIR?= /usr/lib/private
LIBDATADIR?= /usr/libdata
LIBEXECDIR?= /usr/libexec
LINTLIBDIR?= /usr/libdata/lint
Modified: stable/9/share/mk/bsd.prog.mk
==============================================================================
--- stable/9/share/mk/bsd.prog.mk Tue Mar 11 15:46:03 2014 (r263030)
+++ stable/9/share/mk/bsd.prog.mk Tue Mar 11 16:13:03 2014 (r263031)
@@ -52,6 +52,10 @@ STRIP?= -s
LDFLAGS+= -static
.endif
+.if defined(USEPRIVATELIB)
+LDFLAGS+= -L${_SHLIBDIRPREFIX}${LIBPRIVATEDIR} -rpath ${LIBPRIVATEDIR}
+.endif
+
.if ${MK_DEBUG_FILES} != "no"
PROG_FULL=${PROG}.full
# Use ${DEBUGDIR} for base system debug files, else .debug subdirectory
More information about the svn-src-stable-9
mailing list