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: AS17314 8.43.84.0/22 X-Spam-Status: No, score=-3.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RDNS_DYNAMIC,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (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 1A04E1F8C6 for ; Tue, 14 Sep 2021 16:57:01 +0000 (UTC) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DDE4C3857C66 for ; Tue, 14 Sep 2021 16:56:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DDE4C3857C66 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1631638619; bh=M75dR0ZqDjMI3fIiI7v7DmkY2xaV/NyV+rCQ+0K/EAo=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=dkMnJZ8xidpxW5olFQeEd2Nh8Dch4YwkEZhWBPo4yBUOIc+8ZwLNLTy7n8p33xYZj QDYtKgj7uNubhe2YByzLWNUaH14uiz0ag268lo4T2RIMFCxjZ02IwGjKlt0Egldvfa qv3dKw/875VTm2yGfb/wof9SRJGoI0SfAOdgb8L8= Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) by sourceware.org (Postfix) with ESMTPS id DD96B3858402 for ; Tue, 14 Sep 2021 16:56:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org DD96B3858402 Received: by mail-pg1-x52e.google.com with SMTP id s11so13307391pgr.11 for ; Tue, 14 Sep 2021 09:56:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=M75dR0ZqDjMI3fIiI7v7DmkY2xaV/NyV+rCQ+0K/EAo=; b=xGzVRoxubocurcIJlqGSnKY1s6kQc34ptx+o2yMgO3Vv+6kn1JfxvpnFqR3AZQ68lY w2SxucXEnPgTta2DakCaC26u54kS2Fltk96BF6fOOQ1JshP1trWGld+6pVdK2H+em3Gx bnjiVi7e9imeFbtt2UjI2Klyx5sOZv8kK+PEb2cXUm3z3Apx6qPVMRNjmemLIFKQD+hs O8P67rdG+1PY3XYI6j5z7+eIkiodXx8FGytAo/3ifW5PXNi3O5kj1+VJK5ocrnOlqq3V yXwS7Pyq8glPfLviNGU9QD4RoWO8Q9Isa7ATRGgulVVxmg3il7rS9BdDsfonFcVm8ABB iL+w== X-Gm-Message-State: AOAM532XpjSUraLrUE2lZ4bGSABpQfod5cxnDRygiGCtFwWcxSlNvapj uEqhWtWSrD9n/C196cRHXR3Xft2gpGo= X-Google-Smtp-Source: ABdhPJzFp+QA+BZX5fx9r2yO4q8jvCE5Vg2sS0ePHJIWphjeo417sqxDKTqM/SiURFthVa3UJOvPaA== X-Received: by 2002:a63:c0a:: with SMTP id b10mr16253572pgl.447.1631638600018; Tue, 14 Sep 2021 09:56:40 -0700 (PDT) Received: from gnu-gram-1.localdomain (cpe-24-165-14-145.hawaii.res.rr.com. [24.165.14.145]) by smtp.gmail.com with ESMTPSA id u24sm11807742pfm.27.2021.09.14.09.56.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Sep 2021 09:56:39 -0700 (PDT) Received: from gnu-gram-1.. (localhost [IPv6:::1]) by gnu-gram-1.localdomain (Postfix) with ESMTP id DA5BFE0072; Tue, 14 Sep 2021 09:56:37 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH v11 0/1] Extend struct r_debug to support multiple namespaces Date: Tue, 14 Sep 2021 09:56:36 -0700 Message-Id: <20210914165637.439860-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 Errors-To: libc-alpha-bounces+e=80x24.org@sourceware.org Sender: "Libc-alpha" Changes in the v11 patch: 1. Append the new namespace to the end of the linked list after setting up the new namespace. Changes in the v10 patch: 1. Append the new namespace to the end of the linked list. Changes in the v9 patch: 1. Remove compatibility in comments for _r_debug. 2. Update rtld-debugger-interface.txt for active namespace. 3. Update tst-dlmopen4.c to verify r_version == 1 before dlmopen. 4. Use TEST_COMPARE and TEST_COMPARE_STRING in tst-dlmopen4.c. Changes in the v8 patch: 1. Check base.r_brk == 0, instead of r_next == NULL, to decide if a namespace has been initialized. r_next can be NULL after initialization, but base.r_brk must be non-zero after initialization. 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 | 81 +++++++++++++++++++++++++-------- elf/dl-load.c | 2 +- elf/dl-open.c | 10 ++-- elf/dl-reloc-static-pie.c | 2 +- elf/link.h | 35 ++++++++++---- elf/rtld-debugger-interface.txt | 15 ++++++ elf/rtld.c | 4 +- elf/tst-dlmopen4.c | 72 +++++++++++++++++++++++++++++ include/link.h | 4 ++ sysdeps/generic/ldsodefs.h | 12 +++-- 16 files changed, 258 insertions(+), 45 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