Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 29 Mar 2018 19:32:25 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r331742 - in stable/11: contrib/mdocml lib lib/libc/gen lib/libdl share/mk
Message-ID:  <201803291932.w2TJWPEm082290@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Thu Mar 29 19:32:25 2018
New Revision: 331742
URL: https://svnweb.freebsd.org/changeset/base/331742

Log:
  MFC r320872:
  Create libdl.so.1 as a filter for libc.so.7 which exports public dl*
  functions.

Added:
  stable/11/lib/libdl/
     - copied from r320872, head/lib/libdl/
Modified:
  stable/11/contrib/mdocml/lib.in
  stable/11/lib/Makefile
  stable/11/lib/libc/gen/dlfcn.c
  stable/11/lib/libc/gen/dlopen.3
  stable/11/share/mk/bsd.libnames.mk
  stable/11/share/mk/bsd.linker.mk
  stable/11/share/mk/src.libnames.mk
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/contrib/mdocml/lib.in
==============================================================================
--- stable/11/contrib/mdocml/lib.in	Thu Mar 29 19:29:12 2018	(r331741)
+++ stable/11/contrib/mdocml/lib.in	Thu Mar 29 19:32:25 2018	(r331742)
@@ -46,6 +46,7 @@ LINE("libdevctl",	"Device Control Library (libdevctl, 
 LINE("libdevinfo",	"Device and Resource Information Utility Library (libdevinfo, \\-ldevinfo)")
 LINE("libdevstat",	"Device Statistics Library (libdevstat, \\-ldevstat)")
 LINE("libdisk",		"Interface to Slice and Partition Labels Library (libdisk, \\-ldisk)")
+LINE("libdl",		"Dynamic Linker Services Filter (libdl, \\-ldl)")
 LINE("libdm",		"Device Mapper Library (libdm, \\-ldm)")
 LINE("libdwarf",	"DWARF Access Library (libdwarf, \\-ldwarf)")
 LINE("libedit",		"Command Line Editor Library (libedit, \\-ledit)")

Modified: stable/11/lib/Makefile
==============================================================================
--- stable/11/lib/Makefile	Thu Mar 29 19:29:12 2018	(r331741)
+++ stable/11/lib/Makefile	Thu Mar 29 19:32:25 2018	(r331742)
@@ -47,6 +47,7 @@ SUBDIR=	${SUBDIR_BOOTSTRAP} \
 	libdevdctl \
 	libdevinfo \
 	libdevstat \
+	${_libdl} \
 	libdwarf \
 	libedit \
 	${_libefivar} \
@@ -273,6 +274,10 @@ _librtld_db=	librtld_db
 .if ${MACHINE_CPUARCH} == "powerpc"
 _libproc=	libproc
 _librtld_db=	librtld_db
+.endif
+
+.if defined(LINKER_FEATURES) && ${LINKER_FEATURES:Mfilter}
+_libdl=		libdl
 .endif
 
 .if ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "arm" || \

Modified: stable/11/lib/libc/gen/dlfcn.c
==============================================================================
--- stable/11/lib/libc/gen/dlfcn.c	Thu Mar 29 19:29:12 2018	(r331741)
+++ stable/11/lib/libc/gen/dlfcn.c	Thu Mar 29 19:32:25 2018	(r331742)
@@ -27,6 +27,8 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
+#if !defined(IN_LIBDL) || defined(PIC)
+
 /*
  * Linkage to services provided by the dynamic linker.
  */
@@ -157,6 +159,7 @@ _rtld_thread_init(void *li __unused)
 	_rtld_error(sorry);
 }
 
+#ifndef IN_LIBDL
 static pthread_once_t dl_phdr_info_once = PTHREAD_ONCE_INIT;
 static struct dl_phdr_info phdr_info;
 
@@ -192,6 +195,7 @@ dl_init_phdr_info(void)
 	}
 	phdr_info.dlpi_adds = 1;
 }
+#endif
 
 #pragma weak dl_iterate_phdr
 int
@@ -199,11 +203,15 @@ dl_iterate_phdr(int (*callback)(struct dl_phdr_info *,
     void *data __unused)
 {
 
+#ifndef IN_LIBDL
 	__init_elf_aux_vector();
 	if (__elf_aux_vector == NULL)
 		return (1);
 	_once(&dl_phdr_info_once, dl_init_phdr_info);
 	return (callback(&phdr_info, sizeof(phdr_info), data));
+#else
+	return (0);
+#endif
 }
 
 #pragma weak fdlopen
@@ -251,3 +259,5 @@ _rtld_is_dlopened(void *arg __unused)
 
 	return (0);
 }
+
+#endif /* !defined(IN_LIBDL) || defined(PIC) */

Modified: stable/11/lib/libc/gen/dlopen.3
==============================================================================
--- stable/11/lib/libc/gen/dlopen.3	Thu Mar 29 19:29:12 2018	(r331741)
+++ stable/11/lib/libc/gen/dlopen.3	Thu Mar 29 19:32:25 2018	(r331742)
@@ -32,7 +32,7 @@
 .\" @(#) dlopen.3 1.6 90/01/31 SMI
 .\" $FreeBSD$
 .\"
-.Dd February 14, 2015
+.Dd July 7, 2017
 .Dt DLOPEN 3
 .Os
 .Sh NAME
@@ -376,6 +376,14 @@ option to
 .Xr ld 1
 for symbols defined in the executable to become visible to
 .Fn dlsym .
+.Pp
+Other ELF platforms require linking with
+.Lb libdl
+to provide
+.Fn dlopen
+and other functions.
+.Fx
+does not require linking with the library, but supports it for compatibility.
 .Pp
 In previous implementations, it was necessary to prepend an underscore
 to all external symbols in order to gain symbol

Modified: stable/11/share/mk/bsd.libnames.mk
==============================================================================
--- stable/11/share/mk/bsd.libnames.mk	Thu Mar 29 19:29:12 2018	(r331741)
+++ stable/11/share/mk/bsd.libnames.mk	Thu Mar 29 19:32:25 2018	(r331742)
@@ -54,6 +54,7 @@ LIBDEVDCTL?=	${DESTDIR}${LIBDIR_BASE}/libdevdctl.a
 LIBDEVINFO?=	${DESTDIR}${LIBDIR_BASE}/libdevinfo.a
 LIBDEVSTAT?=	${DESTDIR}${LIBDIR_BASE}/libdevstat.a
 LIBDIALOG?=	${DESTDIR}${LIBDIR_BASE}/libdialog.a
+LIBDL?=		${DESTDIR}${LIBDIR_BASE}/libdl.a
 LIBDNS?=	${DESTDIR}${LIBDIR_BASE}/libdns.a
 LIBDPV?=	${DESTDIR}${LIBDIR_BASE}/libdpv.a
 LIBDTRACE?=	${DESTDIR}${LIBDIR_BASE}/libdtrace.a

Modified: stable/11/share/mk/bsd.linker.mk
==============================================================================
--- stable/11/share/mk/bsd.linker.mk	Thu Mar 29 19:29:12 2018	(r331741)
+++ stable/11/share/mk/bsd.linker.mk	Thu Mar 29 19:32:25 2018	(r331742)
@@ -70,6 +70,9 @@ ${X_}LINKER_FEATURES=
 .if ${${X_}LINKER_TYPE} != "bfd" || ${${X_}LINKER_VERSION} > 21750
 ${X_}LINKER_FEATURES+=	build-id
 .endif
+.if ${${X_}LINKER_TYPE} == "bfd"
+${X_}LINKER_FEATURES+=	filter
+.endif
 .endif
 .else
 # Use LD's values

Modified: stable/11/share/mk/src.libnames.mk
==============================================================================
--- stable/11/share/mk/src.libnames.mk	Thu Mar 29 19:29:12 2018	(r331741)
+++ stable/11/share/mk/src.libnames.mk	Thu Mar 29 19:32:25 2018	(r331742)
@@ -87,6 +87,7 @@ _LIBRARIES=	\
 		devinfo \
 		devstat \
 		dialog \
+		dl \
 		dpv \
 		dtrace \
 		dwarf \



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201803291932.w2TJWPEm082290>