aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Belousov <kib@FreeBSD.org>2023-11-29 18:30:59 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2023-12-07 00:27:34 +0000
commit07fa8d431c0ea291a0e4b79a0bb81707d0b119e6 (patch)
tree2cef01fa685341cf8acd0786db05e7c9fc203e40
parent7fd0973775aa9a293739afa0c5068f77ba88cb17 (diff)
downloadsrc-07fa8d431c0ea291a0e4b79a0bb81707d0b119e6.tar.gz
src-07fa8d431c0ea291a0e4b79a0bb81707d0b119e6.zip
RTLD_DEEPBIND: make lookup not just symbolic, but walk all refobj' DAGs
PR: 275393 (cherry picked from commit 9daf6cd0f46416d9c6eb0411ea6042cd42b8a9bc)
-rw-r--r--libexec/rtld-elf/rtld.c8
-rw-r--r--libexec/rtld-elf/rtld.h1
2 files changed, 7 insertions, 2 deletions
diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c
index ac492b1071f0..218e984bdd88 100644
--- a/libexec/rtld-elf/rtld.c
+++ b/libexec/rtld-elf/rtld.c
@@ -3789,7 +3789,7 @@ dlopen_object(const char *name, int fd, Obj_Entry *refobj, int lo_flags,
if (!obj->init_done) {
/* We loaded something new and have to init something. */
if ((lo_flags & RTLD_LO_DEEPBIND) != 0)
- obj->symbolic = true;
+ obj->deepbind = true;
result = 0;
if ((lo_flags & (RTLD_LO_EARLY | RTLD_LO_IGNSTLS)) == 0 &&
obj->static_tls && !allocate_tls_offset(obj)) {
@@ -4615,7 +4615,8 @@ symlook_default(SymLook *req, const Obj_Entry *refobj)
if (refobj->symbolic || req->defobj_out != NULL)
donelist_check(&donelist, refobj);
- symlook_global(req, &donelist);
+ if (!refobj->deepbind)
+ symlook_global(req, &donelist);
/* Search all dlopened DAGs containing the referencing object. */
STAILQ_FOREACH(elm, &refobj->dldags, link) {
@@ -4631,6 +4632,9 @@ symlook_default(SymLook *req, const Obj_Entry *refobj)
}
}
+ if (refobj->deepbind)
+ symlook_global(req, &donelist);
+
/*
* Search the dynamic linker itself, and possibly resolve the
* symbol from there. This is how the application links to
diff --git a/libexec/rtld-elf/rtld.h b/libexec/rtld-elf/rtld.h
index e2fb3de470c3..3111e54a2e08 100644
--- a/libexec/rtld-elf/rtld.h
+++ b/libexec/rtld-elf/rtld.h
@@ -245,6 +245,7 @@ typedef struct Struct_Obj_Entry {
bool ver_checked : 1; /* True if processed by rtld_verify_object_versions */
bool textrel : 1; /* True if there are relocations to text seg */
bool symbolic : 1; /* True if generated with "-Bsymbolic" */
+ bool deepbind : 1; /* True if loaded with RTLD_DEEPBIND" */
bool bind_now : 1; /* True if all relocations should be made first */
bool traced : 1; /* Already printed in ldd trace output */
bool jmpslots_done : 1; /* Already have relocated the jump slots */