From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS3215 2.6.0.0/16 X-Spam-Status: No, score=-4.2 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 15B971F8C6 for ; Tue, 7 Sep 2021 15:16:32 +0000 (UTC) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 12421385781B for ; Tue, 7 Sep 2021 15:16:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 12421385781B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1631027791; bh=yN4her/92HFIvtYxkuxiAq+BYO1YJ2zOZLt7an2dYn4=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=mAXYeldYWwNjJO0ZDeTNkTIr+fJMeBMiDlwJDgd3RILGGBc3lwZlVHy5azDMACaki OS/cjQqK1hMPIcceYzTrbNH5nlazWfKo5IpAWcuFPq6juQ8ugmynRuIxMkPNGtJt7a +8F3IUhXBJ66yDU34kFJ0X/30Iy7YQizOeD+iA68= Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by sourceware.org (Postfix) with ESMTPS id 764C53858002; Tue, 7 Sep 2021 15:15:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 764C53858002 Received: by mail-pf1-x42a.google.com with SMTP id q22so3623365pfu.0; Tue, 07 Sep 2021 08:15:10 -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=yN4her/92HFIvtYxkuxiAq+BYO1YJ2zOZLt7an2dYn4=; b=VChbbNbyXhH6l3lwYflwIvTdBKI4bSgKGnU1gi+58kBVMFHiDwEamDf1YgH/+pzmhj tiRD81sayVwMjgD87NW8DUMoSysJdl7rQVFFBWG2VwWorM7Sr3/tL/xvgcDLaOYj+L6a HnxTuREgN/rJ+HMRUaKFWIPCz5wwm9kVh3zVE9Hy3ciaPn9k9PMQSwhoD0xV3sVElRiU DF6yhgII2seJ+o/iZZaABRbObKD6JjkoGHzZK882Dx9nmaEFxXiPZRXLlEAibtcWzdMx /Eu7Bb4xzGRRuebL5znTB/OLpMih9ZN33TLTrDh+XfDSGDb5IF/+mcsuLlQdPhBKeIoq Zh/A== X-Gm-Message-State: AOAM5312cb0WbWV4/7jIqT2Ts80bwCUCjpQoJhAZ1kgQYxfXBXowVBl9 RaC+885nhCfDUpbigvdy+zw= X-Google-Smtp-Source: ABdhPJzid71Lz5lnZ4O34PnoUfqWSW8uFNt7faTM+V2KgI2WSm445U5YJcY0nAWuMgmkgDyWgbiPgA== X-Received: by 2002:a63:f84f:: with SMTP id v15mr17441733pgj.204.1631027709505; Tue, 07 Sep 2021 08:15:09 -0700 (PDT) Received: from gnu-cfl-2.localdomain ([172.56.39.243]) by smtp.gmail.com with ESMTPSA id p4sm13539184pgc.15.2021.09.07.08.15.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Sep 2021 08:15:08 -0700 (PDT) Received: from gnu-cfl-2.. (localhost [IPv6:::1]) by gnu-cfl-2.localdomain (Postfix) with ESMTP id 5C94DC019C; Tue, 7 Sep 2021 08:15:07 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH v7 0/1] Extend struct r_debug to support multiple namespaces Date: Tue, 7 Sep 2021 08:15:06 -0700 Message-Id: <20210907151507.2955460-1-hjl.tools@gmail.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: "H.J. Lu via Libc-alpha" Reply-To: "H.J. Lu" Cc: Florian Weimer , gdb@sourceware.org, libc-coord@lists.openwall.com Errors-To: libc-alpha-bounces+e=80x24.org@sourceware.org Sender: "Libc-alpha" Changes in the v7 patch: 1. Rewrite dl-debug-symbols.S and remove dl-debug-compat-symbols.c. 2. Bump r_version to 2 only when multiple namespaces are used. 3. Verify r_version == 1 without multiple namespaces. 4. Keep the empty (unused) namespace on the namespace linked list. 5. Use atomic_store_release to update r_version and r_next. 6. Add _dl_debug_update without adding the namespace to the namespace linked list. Changes in the v6 patch: 1. Add comments for dl-debug-compat-symbols.[o|os] usage. 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 when multiple namespaces are used. 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. Initialize the r_debug_extended structure. Bump r_version to 2 for the new namespace and add the new namespace to the namespace linked list. 4. Add _dl_debug_update to return the address of struct r_debug' of a namespace. 5. Add a hidden symbol, _r_debug_extended, for struct r_debug_extended. 6. 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. This fixes BZ #15971. H.J. Lu (1): Extend struct r_debug to support multiple namespaces [BZ #15971] NEWS | 11 ++++- csu/Makefile | 3 ++ csu/rtld-sizes.sym | 6 +++ elf/Makefile | 7 +++- elf/dl-close.c | 2 +- elf/dl-debug-symbols.S | 37 +++++++++++++++++ elf/dl-debug.c | 71 ++++++++++++++++++++++++--------- elf/dl-load.c | 2 +- elf/dl-open.c | 10 ++--- elf/dl-reloc-static-pie.c | 2 +- elf/link.h | 36 ++++++++++++----- elf/rtld-debugger-interface.txt | 14 +++++++ elf/rtld.c | 4 +- elf/tst-dlmopen4.c | 68 +++++++++++++++++++++++++++++++ elf/tst-dlopen-nodelete-reloc.c | 2 + include/link.h | 4 ++ sysdeps/generic/ldsodefs.h | 12 ++++-- 17 files changed, 245 insertions(+), 46 deletions(-) create mode 100644 csu/rtld-sizes.sym create mode 100644 elf/dl-debug-symbols.S create mode 100644 elf/tst-dlmopen4.c -- 2.31.1