public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/maskray/unnest] elf: Copy l_addr/l_ld when adding ld.so to a new namespace
@ 2021-10-02 5:15 Fangrui Song
0 siblings, 0 replies; only message in thread
From: Fangrui Song @ 2021-10-02 5:15 UTC (permalink / raw)
To: glibc-cvs
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=88361b408b9dbd313f15413cc2e6be0f1cafb01a
commit 88361b408b9dbd313f15413cc2e6be0f1cafb01a
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Tue Aug 17 19:36:04 2021 -0700
elf: Copy l_addr/l_ld when adding ld.so to a new namespace
When add ld.so to a new namespace, we don't actually load ld.so. We
create a new link map and refers the real one for almost everything.
Copy l_addr and l_ld from the real ld.so link map to avoid GDB warning:
warning: .dynamic section for ".../elf/ld-linux-x86-64.so.2" is not at the expected address (wrong library or version mismatch?)
when handling shared library loaded by dlmopen.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Diff:
---
elf/dl-load.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/elf/dl-load.c b/elf/dl-load.c
index 6ea71077af..99c5ab83b3 100644
--- a/elf/dl-load.c
+++ b/elf/dl-load.c
@@ -1026,6 +1026,10 @@ _dl_map_object_from_fd (const char *name, const char *origname, int fd,
/* Refer to the real descriptor. */
l->l_real = &GL(dl_rtld_map);
+ /* Copy l_addr and l_ld to avoid a GDB warning with dlmopen(). */
+ l->l_addr = l->l_real->l_addr;
+ l->l_ld = l->l_real->l_ld;
+
/* No need to bump the refcount of the real object, ld.so will
never be unloaded. */
__close_nocancel (fd);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-10-02 5:15 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-02 5:15 [glibc/maskray/unnest] elf: Copy l_addr/l_ld when adding ld.so to a new namespace Fangrui Song
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).