rtld.c has /* Fill in the pointer in the dynamic linker's own dynamic section, in case you run gdb on the dynamic linker directly. */ if (GL(dl_rtld_map).l_info[DT_DEBUG] != NULL) GL(dl_rtld_map).l_info[DT_DEBUG]->d_un.d_ptr = (ElfW(Addr)) r; But linker never generates DT_DEBUG in shared libraries. It should be removed or linker should add a new option to generate DT_DEBUG in shared libraries.
The master branch has been updated by H.J. Lu <hjl@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=3234a31b489707f19ec6d4c9909af06f20ddb901 commit 3234a31b489707f19ec6d4c9909af06f20ddb901 Author: H.J. Lu <hjl.tools@gmail.com> Date: Mon Aug 2 13:52:36 2021 -0700 ld.so: Don't fill the DT_DEBUG entry in ld.so [BZ #28129] Linker creates the DT_DEBUG entry only in executables. Don't fill the non-existent DT_DEBUG entry in ld.so with the run-time address of the r_debug structure. This fixes BZ #28129.
Fixed for 2.35.