summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2018-03-29 19:32:25 +0000
committerkib <kib@FreeBSD.org>2018-03-29 19:32:25 +0000
commitb26dff771d448945c86a9576f29e2cdbbe34d1e3 (patch)
treefcb145c76308ad45bb1bc07c73072d3d6f759ad9
parentf0a41c1b5e180738f503b7a01b8af106013d3b6f (diff)
downloadFreeBSD-src-b26dff771d448945c86a9576f29e2cdbbe34d1e3.zip
FreeBSD-src-b26dff771d448945c86a9576f29e2cdbbe34d1e3.tar.gz
MFC r320872:
Create libdl.so.1 as a filter for libc.so.7 which exports public dl* functions.
-rw-r--r--contrib/mdocml/lib.in1
-rw-r--r--lib/Makefile5
-rw-r--r--lib/libc/gen/dlfcn.c10
-rw-r--r--lib/libc/gen/dlopen.310
-rw-r--r--lib/libdl/Makefile15
-rw-r--r--lib/libdl/Symbol.map20
-rw-r--r--share/mk/bsd.libnames.mk1
-rw-r--r--share/mk/bsd.linker.mk3
-rw-r--r--share/mk/src.libnames.mk1
9 files changed, 65 insertions, 1 deletions
diff --git a/contrib/mdocml/lib.in b/contrib/mdocml/lib.in
index e74b8ac..76691ec 100644
--- a/contrib/mdocml/lib.in
+++ b/contrib/mdocml/lib.in
@@ -46,6 +46,7 @@ LINE("libdevctl", "Device Control Library (libdevctl, \\-ldevctl)")
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)")
diff --git a/lib/Makefile b/lib/Makefile
index ae8ab9b..242c463 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -47,6 +47,7 @@ SUBDIR= ${SUBDIR_BOOTSTRAP} \
libdevdctl \
libdevinfo \
libdevstat \
+ ${_libdl} \
libdwarf \
libedit \
${_libefivar} \
@@ -275,6 +276,10 @@ _libproc= libproc
_librtld_db= librtld_db
.endif
+.if defined(LINKER_FEATURES) && ${LINKER_FEATURES:Mfilter}
+_libdl= libdl
+.endif
+
.if ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "arm" || \
${MACHINE_CPUARCH} == "riscv"
_libproc= libproc
diff --git a/lib/libc/gen/dlfcn.c b/lib/libc/gen/dlfcn.c
index 393b02a..55e7fc7 100644
--- a/lib/libc/gen/dlfcn.c
+++ b/lib/libc/gen/dlfcn.c
@@ -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 *, size_t, void *) __unused,
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) */
diff --git a/lib/libc/gen/dlopen.3 b/lib/libc/gen/dlopen.3
index 1963528..202f1af 100644
--- a/lib/libc/gen/dlopen.3
+++ b/lib/libc/gen/dlopen.3
@@ -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
@@ -377,6 +377,14 @@ option to
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
compatibility with object code compiled from the C language.
diff --git a/lib/libdl/Makefile b/lib/libdl/Makefile
new file mode 100644
index 0000000..8feb782
--- /dev/null
+++ b/lib/libdl/Makefile
@@ -0,0 +1,15 @@
+# $FreeBSD$
+
+LIB=dl
+SHLIB_MAJOR=1
+
+.PATH: ${SRCTOP}/lib/libc/gen
+CFLAGS+=-I${SRCTOP}/lib/libc/include
+CFLAGS+=-DIN_LIBDL
+LDFLAGS+=-Wl,-F,libc.so.7
+VERSION_DEF=${SRCTOP}/lib/libc/Versions.def
+SYMBOL_MAPS=${.CURDIR}/Symbol.map
+
+SRCS = dlfcn.c
+
+.include <bsd.lib.mk>
diff --git a/lib/libdl/Symbol.map b/lib/libdl/Symbol.map
new file mode 100644
index 0000000..82ab601
--- /dev/null
+++ b/lib/libdl/Symbol.map
@@ -0,0 +1,20 @@
+/*
+ * $FreeBSD$
+ */
+
+FBSD_1.0 {
+ dladdr;
+ dlclose;
+ dlerror;
+ dlfunc;
+ dlopen;
+ dlsym;
+ dlvsym;
+ dlinfo;
+ dl_iterate_phdr;
+};
+
+
+FBSD_1.3 {
+ fdlopen;
+};
diff --git a/share/mk/bsd.libnames.mk b/share/mk/bsd.libnames.mk
index 28be843..07e7a4c 100644
--- a/share/mk/bsd.libnames.mk
+++ b/share/mk/bsd.libnames.mk
@@ -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
diff --git a/share/mk/bsd.linker.mk b/share/mk/bsd.linker.mk
index 90691f7..791ee16 100644
--- a/share/mk/bsd.linker.mk
+++ b/share/mk/bsd.linker.mk
@@ -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
diff --git a/share/mk/src.libnames.mk b/share/mk/src.libnames.mk
index bfe8c4f..ac3f9c2 100644
--- a/share/mk/src.libnames.mk
+++ b/share/mk/src.libnames.mk
@@ -87,6 +87,7 @@ _LIBRARIES= \
devinfo \
devstat \
dialog \
+ dl \
dpv \
dtrace \
dwarf \
OpenPOWER on IntegriCloud