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-Status: No, score=-4.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, 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 D0A761F5AE for ; Fri, 26 Jun 2020 19:32:52 +0000 (UTC) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id F11BB388C03C; Fri, 26 Jun 2020 19:32:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F11BB388C03C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1593199962; bh=mbYCkopn2k6PydWBW01day3Wie0S7QcfTbkcMurogpo=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=UqVh7Fv9SWVytOQ0d5qtcAuSRKP4WGPRRMDfCB1dhhhKHA4OO8RZZiqKkqAkudx5x 8Xs2v+gV4wu3OsdKdH0dp42iOGfBsbZvI9pzCuvxcj0phl/FMiHq8aN/nRcU7Li3PR XLOc9Z6u1EmtCj14UTb2qHkwJmdOBLNGG2G9syOU= Received: from rcdn-iport-5.cisco.com (rcdn-iport-5.cisco.com [173.37.86.76]) by sourceware.org (Postfix) with ESMTPS id 16C66386F83E for ; Fri, 26 Jun 2020 19:32:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 16C66386F83E X-IronPort-AV: E=Sophos;i="5.75,282,1589241600"; d="scan'208";a="528276816" Received: from alln-core-8.cisco.com ([173.36.13.141]) by rcdn-iport-5.cisco.com with ESMTP/TLS/DHE-RSA-SEED-SHA; 26 Jun 2020 19:32:34 +0000 Received: from zorba.cisco.com ([10.24.15.228]) by alln-core-8.cisco.com (8.15.2/8.15.2) with ESMTP id 05QJWSW6030756; Fri, 26 Jun 2020 19:32:30 GMT To: libc-alpha@sourceware.org Subject: [RFC PATCH 3/3] add r_debug multiple namespaces support Date: Fri, 26 Jun 2020 12:32:28 -0700 Message-Id: <20200626193228.1953-4-danielwa@cisco.com> X-Mailer: git-send-email 2.17.1 X-Auto-Response-Suppress: DR, OOF, AutoReply X-Outbound-SMTP-Client: 10.24.15.228, [10.24.15.228] X-Outbound-Node: alln-core-8.cisco.com 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: Daniel Walker via Libc-alpha Reply-To: Daniel Walker Cc: Conan C Huang , Jeremy Stenglein , xe-linux-external@cisco.com Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" From: Conan C Huang GLIBC Bugzilla: 15971 GDB Bugzilla: 11839 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). This solution converts r_debug into a linked-list, where each element correlates to an unique namespace. Debugger (GDB) can traverse r_debug linked-list to retrieve information for all loaded namespaces. --- elf/dl-debug.c | 13 ++++++++++--- elf/link.h | 4 ++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/elf/dl-debug.c b/elf/dl-debug.c index 4b3d3ad6ba..7eba477fd3 100644 --- a/elf/dl-debug.c +++ b/elf/dl-debug.c @@ -44,20 +44,27 @@ struct r_debug _r_debug; struct r_debug * _dl_debug_initialize (ElfW(Addr) ldbase, Lmid_t ns) { - struct r_debug *r; + struct r_debug *r, *rp; if (ns == LM_ID_BASE) r = &_r_debug; else - r = &GL(dl_ns)[ns]._ns_debug; + { + r = &GL(dl_ns)[ns]._ns_debug; + rp = &GL(dl_ns)[ns - 1]._ns_debug; + rp->next = r; + if (ns - 1 == LM_ID_BASE) + _r_debug.next = r; + } if (r->r_map == NULL || ldbase != 0) { /* Tell the debugger where to find the map of loaded objects. */ - r->r_version = 1 /* R_DEBUG_VERSION XXX */; + r->r_version = 3 /* R_DEBUG_VERSION XXX */; r->r_ldbase = ldbase ?: _r_debug.r_ldbase; r->r_map = (void *) GL(dl_ns)[ns]._ns_loaded; r->r_brk = (ElfW(Addr)) &_dl_debug_state; + r->next = NULL; } return r; diff --git a/elf/link.h b/elf/link.h index 0048ad5d4d..5a42511636 100644 --- a/elf/link.h +++ b/elf/link.h @@ -61,6 +61,10 @@ struct r_debug } r_state; ElfW(Addr) r_ldbase; /* Base address the linker is loaded at. */ + + /* Link to next r_debug struct. Each r_debug struct represents a + different namespace. The first r_debug struct is the default. */ + struct r_debug *next; }; /* This is the instance of that structure used by the dynamic linker. */ -- 2.17.1