Bug 28129

Summary: Unnecessary check DT_DEBUG in ld.so
Product: glibc Reporter: H.J. Lu <hjl.tools>
Component: dynamic-linkAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: 2.34   
Target Milestone: 2.35   
Host: Target:
Build: Last reconfirmed:

Description H.J. Lu 2021-07-24 14:24:24 UTC
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.
Comment 1 Sourceware Commits 2021-10-06 16:44:23 UTC
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.
Comment 2 H.J. Lu 2021-10-06 16:44:55 UTC
Fixed for 2.35.