Implement RTLD_DEEPBIND.
PR: 246462 Tested by: Martin Birgmeier <d8zNeCFG@aon.at> Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D24841
This commit is contained in:
parent
8ffb1c8ce1
commit
1659238a0c
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=361073
@ -47,6 +47,8 @@
|
|||||||
#define RTLD_TRACE 0x200 /* Trace loaded objects and exit. */
|
#define RTLD_TRACE 0x200 /* Trace loaded objects and exit. */
|
||||||
#define RTLD_NODELETE 0x01000 /* Do not remove members. */
|
#define RTLD_NODELETE 0x01000 /* Do not remove members. */
|
||||||
#define RTLD_NOLOAD 0x02000 /* Do not load if not already loaded. */
|
#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().
|
* Request arguments for dlinfo().
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
.\" @(#) dlopen.3 1.6 90/01/31 SMI
|
.\" @(#) dlopen.3 1.6 90/01/31 SMI
|
||||||
.\" $FreeBSD$
|
.\" $FreeBSD$
|
||||||
.\"
|
.\"
|
||||||
.Dd January 2, 2019
|
.Dd May 14, 2020
|
||||||
.Dt DLOPEN 3
|
.Dt DLOPEN 3
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
@ -162,6 +162,9 @@ the process address space, otherwise
|
|||||||
is returned.
|
is returned.
|
||||||
Other mode flags may be specified, which will be applied for promotion
|
Other mode flags may be specified, which will be applied for promotion
|
||||||
for the found object.
|
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
|
.El
|
||||||
.Pp
|
.Pp
|
||||||
If
|
If
|
||||||
|
@ -3366,6 +3366,8 @@ rtld_dlopen(const char *name, int fd, int mode)
|
|||||||
lo_flags |= RTLD_LO_NODELETE;
|
lo_flags |= RTLD_LO_NODELETE;
|
||||||
if (mode & RTLD_NOLOAD)
|
if (mode & RTLD_NOLOAD)
|
||||||
lo_flags |= RTLD_LO_NOLOAD;
|
lo_flags |= RTLD_LO_NOLOAD;
|
||||||
|
if (mode & RTLD_DEEPBIND)
|
||||||
|
lo_flags |= RTLD_LO_DEEPBIND;
|
||||||
if (ld_tracing != NULL)
|
if (ld_tracing != NULL)
|
||||||
lo_flags |= RTLD_LO_TRACE | RTLD_LO_IGNSTLS;
|
lo_flags |= RTLD_LO_TRACE | RTLD_LO_IGNSTLS;
|
||||||
|
|
||||||
@ -3417,6 +3419,8 @@ dlopen_object(const char *name, int fd, Obj_Entry *refobj, int lo_flags,
|
|||||||
if (globallist_next(old_obj_tail) != NULL) {
|
if (globallist_next(old_obj_tail) != NULL) {
|
||||||
/* We loaded something new. */
|
/* We loaded something new. */
|
||||||
assert(globallist_next(old_obj_tail) == obj);
|
assert(globallist_next(old_obj_tail) == obj);
|
||||||
|
if ((lo_flags & RTLD_LO_DEEPBIND) != 0)
|
||||||
|
obj->symbolic = true;
|
||||||
result = 0;
|
result = 0;
|
||||||
if ((lo_flags & (RTLD_LO_EARLY | RTLD_LO_IGNSTLS)) == 0 &&
|
if ((lo_flags & (RTLD_LO_EARLY | RTLD_LO_IGNSTLS)) == 0 &&
|
||||||
obj->static_tls && !allocate_tls_offset(obj)) {
|
obj->static_tls && !allocate_tls_offset(obj)) {
|
||||||
|
@ -309,6 +309,7 @@ TAILQ_HEAD(obj_entry_q, Struct_Obj_Entry);
|
|||||||
#define RTLD_LO_EARLY 0x20 /* Do not call ctors, postpone it to the
|
#define RTLD_LO_EARLY 0x20 /* Do not call ctors, postpone it to the
|
||||||
initialization during the image start. */
|
initialization during the image start. */
|
||||||
#define RTLD_LO_IGNSTLS 0x40 /* Do not allocate static TLS */
|
#define RTLD_LO_IGNSTLS 0x40 /* Do not allocate static TLS */
|
||||||
|
#define RTLD_LO_DEEPBIND 0x80 /* Force symbolic for this object */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Symbol cache entry used during relocation to avoid multiple lookups
|
* Symbol cache entry used during relocation to avoid multiple lookups
|
||||||
|
Loading…
Reference in New Issue
Block a user