rtld.c has /* Initialize _r_debug. */ struct r_debug *r = _dl_debug_initialize (GL(dl_rtld_map).l_addr, LM_ID_BASE); if (main_map->l_info[DT_DEBUG] != NULL) /* There is a DT_DEBUG entry in the dynamic section. Fill it in with the run-time address of the r_debug structure */ main_map->l_info[DT_DEBUG]->d_un.d_ptr = (ElfW(Addr)) r; With COPY relocation, the real address of _r_debug may be in the executable if it references _r_debug. If debugger uses DT_DEBUG, it will reference the staled original definition of _r_debug in ld.so.
We can hide _r_debug and add extern struct r_debug * __r_debug_location (void) __attribute_const__; #define _r_debug (*__r_debug_location (())
Nothing should be using _r_debug.
(In reply to Andreas Schwab from comment #2) > Nothing should be using _r_debug. _r_debug is exported and used by glibc tests.
That doesn't matter.