From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) by sourceware.org (Postfix) with ESMTPS id 706703858038; Tue, 24 Aug 2021 13:38:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 706703858038 Received: by mail-pg1-x533.google.com with SMTP id k24so19804487pgh.8; Tue, 24 Aug 2021 06:38:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=oNWbSV6BZYgq6Zye3OOIn7xeVqUDzqm2dPNr8M8a2eA=; b=pKh+0SSQQclnW4wnsheJYDXVvp4vQyLj7LMnFLq9f6/YWK1E/iREiAEwI5/jae3DOX XpvoJdYB35KgDyt7v3NI/50UCVa2cRYRYiVwd6jQNiDf4PAWvrugskcugZUP4J2xdvtN VNqRJ4ulDoxtxeLUpnnYa25eOv6vz9CbHRkNpKDeggy/NdObMtIoYNOnR/KVDrTZuW/n zfDuUgsqdewWOCMKWtn1U2VDflKFXR94JrwXzdteKOBY8p0w7gJqNxTxLSDwO1EPLfNW CN37hMbG4eH5YHT1Fd0sx5RWgoLg8g6Y7PSA2+Fj0VoLHQ9XU2+waMmuF41ue2lFvKnq mZmQ== X-Gm-Message-State: AOAM532xlRy0zn7vn5id7l+uDEG3zciYeNU+J2rdXrH/Vgxse7/Oo+6U mbqK5YSStJCdQRgm/zbgClk= X-Google-Smtp-Source: ABdhPJwZq0SvZ2U4BVFhRhAEJa5N0LXzt1EOzorM0WiKrmF6OugLvIf1SAliarPjz43JFWoyhCiG6A== X-Received: by 2002:a62:aa12:0:b0:3e1:b354:fa3 with SMTP id e18-20020a62aa12000000b003e1b3540fa3mr39564888pff.54.1629812316593; Tue, 24 Aug 2021 06:38:36 -0700 (PDT) Received: from gnu-cfl-2.localdomain ([172.58.38.240]) by smtp.gmail.com with ESMTPSA id p3sm19829121pfw.152.2021.08.24.06.38.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Aug 2021 06:38:36 -0700 (PDT) Received: from gnu-cfl-2.. (localhost [IPv6:::1]) by gnu-cfl-2.localdomain (Postfix) with ESMTP id 9EE0FC0067; Tue, 24 Aug 2021 06:38:34 -0700 (PDT) From: "H.J. Lu" To: libc-alpha@sourceware.org Cc: gdb@sourceware.org, libc-coord@lists.openwall.com, Daniel Walker Subject: [PATCH v5 0/2] Extend struct r_debug to support multiple namespaces Date: Tue, 24 Aug 2021 06:38:32 -0700 Message-Id: <20210824133834.2019570-1-hjl.tools@gmail.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3027.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Aug 2021 13:38:47 -0000 Changes in the v5 patch: 1. Use struct r_debug as the base for struct r_debug_extended. 2. Keep _dl_debug_initialize return type. Changes in the v4 patch: 1. Improve the empty namespace removal from the namespace linked list. 2. Check r_version == 0 for the unused namespace. Changes in the v3 patch: 1. Remove the empty namespace from the namespace linked list. 2. Properly add the new namespace to the linked list. Changes in the v2 patch: 1. Bump r_version to 2. 2. Don't add DT_DEBUGSZ. 3. Add struct r_debug_extended to extend struct r_debug. 4. Don't update the r_state field in the copy of _r_debug in executable since it is not consumed by the program. --- Glibc does not provide an interface for debugger to access libraries loaded in multiple namespaces via dlmopen. The current rtld-debugger interface is described in the file: elf/rtld-debugger-interface.txt under the "Standard debugger interface" heading. This interface only provides access to the first link-map (LM_ID_BASE). 1. Bump r_version to 2. This triggers the GDB bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28236 2. Add struct r_debug_extended to extend struct r_debug into a linked-list, where each element correlates to an unique namespace. 3. Remove the empty namespace from the namespace linked list and clear its r_version field. 4. Add the new namespace, whose r_version field is 0, to the namespace linked list. 5. Initialize the r_debug_extended structure only if its r_version field is 0 and update its r_map field if it is NULL. 6. Add a hidden symbol, _r_debug_extended, for struct r_debug_extended. 7. Provide the compatibility symbol, _r_debug, with size of struct r_debug, as an alise of _r_debug_extended, for programs which reference _r_debug. Glibc does not provide an interface for debugger to access libraries loaded in multiple namespaces via dlmopen. The current rtld-debugger interface is described in the file: elf/rtld-debugger-interface.txt under the "Standard debugger interface" heading. This interface only provides access to the first link-map (LM_ID_BASE). 1. Bump r_version to 2. This triggers the GDB bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28236 2. Add struct r_debug_extended to extend struct r_debug into a linked-list, where each element correlates to an unique namespace. 3. Remove the empty namespace from the namespace linked list and clear its r_version field. 4. Add the new namespace, whose r_version field is 0, to the namespace linked list. 5. Initialize the r_debug_extended structure only if its r_version field is 0 and update its r_map field if it is NULL. 6. Add a hidden symbol, _r_debug_extended, for struct r_debug_extended. 7. Provide the compatibility symbol, _r_debug, with size of struct r_debug, as an alise of _r_debug_extended, for programs which reference _r_debug. H.J. Lu (2): Add declare_object_symbol_alias for assembly codes [BZ #28128] Extend struct r_debug to support multiple namespaces NEWS | 9 ++++- csu/Makefile | 3 ++ csu/rtld-sizes.sym | 4 ++ elf/Makefile | 22 ++++++++++- elf/dl-close.c | 21 ++++++++++ elf/dl-debug-symbols-gen.c | 24 ++++++++++++ elf/dl-debug-symbols.S | 31 +++++++++++++++ elf/dl-debug.c | 46 ++++++++++++---------- elf/dl-reloc-static-pie.c | 2 +- elf/link.h | 36 ++++++++++++----- elf/rtld-debugger-interface.txt | 14 +++++++ elf/rtld.c | 2 +- elf/tst-dlmopen4.c | 68 +++++++++++++++++++++++++++++++++ include/libc-symbols.h | 12 +++--- include/link.h | 4 ++ sysdeps/generic/ldsodefs.h | 8 ++-- 16 files changed, 262 insertions(+), 44 deletions(-) create mode 100644 csu/rtld-sizes.sym create mode 100644 elf/dl-debug-symbols-gen.c create mode 100644 elf/dl-debug-symbols.S create mode 100644 elf/tst-dlmopen4.c -- 2.31.1