From patchwork Sun Dec 15 00:12:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: George Barrett X-Patchwork-Id: 36881 Received: (qmail 91765 invoked by alias); 15 Dec 2019 00:12:15 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 91756 invoked by uid 89); 15 Dec 2019 00:12:15 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.1 spammy=2019-12-15, foreign, images X-HELO: mail.bob131.so Received: from server2.bob131.so (HELO mail.bob131.so) (128.199.153.143) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 15 Dec 2019 00:12:14 +0000 Received: from internal.mail.bob131.so (localhost [127.0.0.1]) by mail.bob131.so (Postfix) with ESMTP id AFD103ECC1 for ; Sun, 15 Dec 2019 00:12:11 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.bob131.so AFD103ECC1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bob131.so; s=default; t=1576368731; bh=HYL8Aoj9Aio9I/FivIdRYahqEiXOknvZhjYiYZMjDQk=; h=Date:From:To:Subject:From; b=MC23TEl9jaK1ojvQ9BbuzgZwk/0HpvVf8m3uM68BonhF8YikrHBNEJAZ2f3rE4f5i +wGJjR2NBEA7sImODjg+2XyEsPg4FQKSfo652DddrMYH9ZwfiQjMEWf+gIljWPLb12 QlGPdorYG0EqlBO3DyOCdcm2YjYzUo6BjlvqIcMV1fY1Kp8f9mAEfbZVi1UxK7rMGn QgVH81MRsex01qefImi+lC3kgCWNtCEHKzOZnU48e00BjrCjP5pwYPZJsLFJzCLjbK FeguEmppwIYw7RB58yeVKml41TorVFlX5HSgQE9EeFi08AGni+kcYAylOQYiWmw8l8 NidX5puZAyECQ== Date: Sun, 15 Dec 2019 11:12:09 +1100 From: George Barrett To: gdb-patches@sourceware.org Subject: [PATCH v2 (w/ ChangeLog)] Fix disabling of solib probes when LD_AUDITing Message-ID: <1ehh33uyr5gra7_h9krnpznz2jqsjw_4593wafg.zlb1mgays0ef@mail.bob131.so> MIME-Version: 1.0 Content-Disposition: inline The SVR4 solib event handler determines whether an event is related to a non-base link namespace by comparing the event's debug struct address to the debug struct address of the initial program image. However, this can fail when using LD_AUDIT as audit libraries are loaded before the loader has initialised the initial program image's debug struct. When the event handler fails to find the debug struct, the probe-based debugger interface is disabled and a warning is flagged to the user. This commit adds a fallback test to help determine whether an event is for a foreign link namespace when the debug struct isn't available. gdb/ChangeLog: 2019-12-15 George Barrett * solib-svr4.c (svr4_handle_solib_event): Add fallback link namespace test for when the debug struct isn't available. --- gdb/solib-svr4.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c index de765576d0..f0c7769ac2 100644 --- a/gdb/solib-svr4.c +++ b/gdb/solib-svr4.c @@ -1942,7 +1942,27 @@ svr4_handle_solib_event (void) /* Always locate the debug struct, in case it moved. */ info->debug_base = 0; if (locate_base (info) == 0) - return; + { + /* It's possible for the reloc_complete probe to be triggered before + the linker has set the DT_DEBUG pointer (for example, when the + linker has finished relocating an LD_AUDIT library or its + dependencies). Since we can't yet handle libraries from other link + namespaces, we don't lose anything by ignoring them here. */ + struct value *link_map_id_val; + try + { + link_map_id_val = pa->prob->evaluate_argument (0, frame); + } + catch (const gdb_exception_error) + { + link_map_id_val = NULL; + } + /* glibc and illumos' libc both define LM_ID_BASE as zero. */ + if (link_map_id_val != NULL && value_as_long (link_map_id_val) != 0) + action = DO_NOTHING; + else + return; + } /* GDB does not currently support libraries loaded via dlmopen into namespaces other than the initial one. We must ignore