svn commit: r361382 - in stable/11: include lib/libc/gen libexec/rtld-elf
Konstantin Belousov
kib at FreeBSD.org
Fri May 22 13:18:44 UTC 2020
Author: kib
Date: Fri May 22 13:18:43 2020
New Revision: 361382
URL: https://svnweb.freebsd.org/changeset/base/361382
Log:
MFC r361073:
Implement RTLD_DEEPBIND.
PR: 246462
Modified:
stable/11/include/dlfcn.h
stable/11/lib/libc/gen/dlopen.3
stable/11/libexec/rtld-elf/rtld.c
stable/11/libexec/rtld-elf/rtld.h
Directory Properties:
stable/11/ (props changed)
Modified: stable/11/include/dlfcn.h
==============================================================================
--- stable/11/include/dlfcn.h Fri May 22 13:17:57 2020 (r361381)
+++ stable/11/include/dlfcn.h Fri May 22 13:18:43 2020 (r361382)
@@ -45,6 +45,8 @@
#define RTLD_TRACE 0x200 /* Trace loaded objects and exit. */
#define RTLD_NODELETE 0x01000 /* Do not remove members. */
#define RTLD_NOLOAD 0x02000 /* Do not load if not already loaded. */
+#define RTLD_DEEPBIND 0x04000 /* Put symbols from the dso ahead of
+ the global list */
/*
* Request arguments for dlinfo().
Modified: stable/11/lib/libc/gen/dlopen.3
==============================================================================
--- stable/11/lib/libc/gen/dlopen.3 Fri May 22 13:17:57 2020 (r361381)
+++ stable/11/lib/libc/gen/dlopen.3 Fri May 22 13:18:43 2020 (r361382)
@@ -32,7 +32,7 @@
.\" @(#) dlopen.3 1.6 90/01/31 SMI
.\" $FreeBSD$
.\"
-.Dd January 2, 2019
+.Dd May 14, 2020
.Dt DLOPEN 3
.Os
.Sh NAME
@@ -162,6 +162,9 @@ the process address space, otherwise
is returned.
Other mode flags may be specified, which will be applied for promotion
for the found object.
+.It Dv RTLD_DEEPBIND
+Symbols from the loaded library are put before global symbols when
+resolving symbolic references originated from the library.
.El
.Pp
If
Modified: stable/11/libexec/rtld-elf/rtld.c
==============================================================================
--- stable/11/libexec/rtld-elf/rtld.c Fri May 22 13:17:57 2020 (r361381)
+++ stable/11/libexec/rtld-elf/rtld.c Fri May 22 13:18:43 2020 (r361382)
@@ -3300,6 +3300,8 @@ rtld_dlopen(const char *name, int fd, int mode)
lo_flags |= RTLD_LO_NODELETE;
if (mode & RTLD_NOLOAD)
lo_flags |= RTLD_LO_NOLOAD;
+ if (mode & RTLD_DEEPBIND)
+ lo_flags |= RTLD_LO_DEEPBIND;
if (ld_tracing != NULL)
lo_flags |= RTLD_LO_TRACE;
@@ -3351,6 +3353,8 @@ dlopen_object(const char *name, int fd, Obj_Entry *ref
if (globallist_next(old_obj_tail) != NULL) {
/* We loaded something new. */
assert(globallist_next(old_obj_tail) == obj);
+ if ((lo_flags & RTLD_LO_DEEPBIND) != 0)
+ obj->symbolic = true;
result = 0;
if ((lo_flags & RTLD_LO_EARLY) == 0 && obj->static_tls &&
!allocate_tls_offset(obj)) {
Modified: stable/11/libexec/rtld-elf/rtld.h
==============================================================================
--- stable/11/libexec/rtld-elf/rtld.h Fri May 22 13:17:57 2020 (r361381)
+++ stable/11/libexec/rtld-elf/rtld.h Fri May 22 13:18:43 2020 (r361382)
@@ -303,6 +303,7 @@ TAILQ_HEAD(obj_entry_q, Struct_Obj_Entry);
#define RTLD_LO_FILTEES 0x10 /* Loading filtee. */
#define RTLD_LO_EARLY 0x20 /* Do not call ctors, postpone it to the
initialization during the image start. */
+#define RTLD_LO_DEEPBIND 0x80 /* Force symbolic for this object */
/*
* Symbol cache entry used during relocation to avoid multiple lookups
More information about the svn-src-all
mailing list