diff options
author | Florian Weimer <fweimer@redhat.com> | 2025-07-04 21:46:30 +0200 |
---|---|---|
committer | Florian Weimer <fweimer@redhat.com> | 2025-07-05 20:15:12 +0200 |
commit | ea85e7d55087075376a29261e722e4fae14ecbe7 (patch) | |
tree | 9915b760ca2e81597b8fcc6583180cea91e2efbe /sysdeps/generic | |
parent | 8329939a37f483a16013dd8af8303cbcb86d92cb (diff) | |
download | glibc-ea85e7d55087075376a29261e722e4fae14ecbe7.zip glibc-ea85e7d55087075376a29261e722e4fae14ecbe7.tar.gz glibc-ea85e7d55087075376a29261e722e4fae14ecbe7.tar.bz2 |
elf: Restore support for _r_debug interpositions and copy relocations
The changes in commit a93d9e03a31ec14405cb3a09aa95413b67067380
("Extend struct r_debug to support multiple namespaces [BZ #15971]")
break the dyninst dynamic instrumentation tool. It brings its
own definition of _r_debug (rather than a declaration).
Furthermore, it turns out it is rather hard to use the proposed
handshake for accessing _r_debug via DT_DEBUG. If applications want
to access _r_debug, they can do so directly if the relevant code has
been built as PIC. To protect against harm from accidental copy
relocations due to linker relaxations, this commit restores copy
relocation support by adjusting both copies if interposition or
copy relocations are in play. Therefore, it is possible to
use a hidden reference in ld.so to access _r_debug.
Only perform the copy relocation initialization if libc has been
loaded. Otherwise, the ld.so search scope can be empty, and the
lookup of the _r_debug symbol mail fail.
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
Diffstat (limited to 'sysdeps/generic')
-rw-r--r-- | sysdeps/generic/ldsodefs.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h index 74931fe..74025f1 100644 --- a/sysdeps/generic/ldsodefs.h +++ b/sysdeps/generic/ldsodefs.h @@ -1098,6 +1098,10 @@ rtld_hidden_proto (_dl_debug_state) extern struct r_debug *_dl_debug_initialize (ElfW(Addr) ldbase, Lmid_t ns) attribute_hidden; +/* This is called after relocation processing to handle a potential + copy relocation for _r_debug. */ +void _dl_debug_post_relocate (struct link_map *main_map) attribute_hidden; + /* Update the `r_map' member and return the address of `struct r_debug' of the namespace NS. */ extern struct r_debug *_dl_debug_update (Lmid_t ns) attribute_hidden; |