]> git.ipfire.org Git - thirdparty/glibc.git/commit
elf: Restore support for _r_debug interpositions and copy relocations
authorFlorian Weimer <fweimer@redhat.com>
Fri, 4 Jul 2025 19:46:30 +0000 (21:46 +0200)
committerFlorian Weimer <fweimer@redhat.com>
Sat, 5 Jul 2025 18:15:12 +0000 (20:15 +0200)
commitea85e7d55087075376a29261e722e4fae14ecbe7
tree9915b760ca2e81597b8fcc6583180cea91e2efbe
parent8329939a37f483a16013dd8af8303cbcb86d92cb
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>
elf/Makefile
elf/dl-debug-symbols.S
elf/dl-debug.c
elf/rtld.c
elf/tst-dlmopen4-nonpic.c [new file with mode: 0644]
elf/tst-dlmopen4-pic.c [new file with mode: 0644]
elf/tst-dlmopen4.c
include/link.h
sysdeps/generic/ldsodefs.h