From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by sourceware.org (Postfix) with ESMTPS id D6C473858002; Mon, 16 Aug 2021 22:03:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D6C473858002 Received: by mail-pl1-x636.google.com with SMTP id w6so15267582plg.9; Mon, 16 Aug 2021 15:03:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=+BBz/3fglgsABNJTsmmOYW40CALnI1zZ+lMgkMSUwkw=; b=LsEGUuMxgDRr4YcRX2ABlNaNneTuWp6iuVrM38MdO1mEUTGM83SgxpsjKN/JfK4Vu2 CRJWtAxt6ShCHYCsrBxYbuLEuvFi7ORJjV7T95KOA7CMFUcYa6HwVEuptU4ljpRw/LyX sg9MCnzTBh7fXYmRnmELBdOAC7ioY3mMMvilRF9FaTdGtjIx+P69g/MudPVIHJdRrQh1 wT8kEb1YIp4hgL/bkOU0S0tKJCQ3WnpuxnUspuhXJIMsNPWoWM9kValQXAPYSA0Ogj5Y cKjeQfgOuxZ+TWP9Xkvv0IrLOfUgNIFBLpU4SOkTFwWKf4AlNH+kF5LuyJQ/eKPO6dYP l3+Q== X-Gm-Message-State: AOAM531TZVoLmzY+1grin3zoDSsiZZZ+4M9kSUM/iMbH8gnkKqBSO8QQ P8KujPSKfFD6t3UQTCN+N0bS782zmdzoBx6vKin7unhmpt4= X-Google-Smtp-Source: ABdhPJy/SULzmey+3YdOfbZJNl5YMCR+zCWbRUKqxcpZLRMnNaJWvgWyfZYTsLdkeNoNrV9P3TRR5WVrIDVp/Wul4fA= X-Received: by 2002:a62:87c5:0:b029:3b5:f90f:c2eb with SMTP id i188-20020a6287c50000b02903b5f90fc2ebmr300450pfe.28.1629151393851; Mon, 16 Aug 2021 15:03:13 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: "H.J. Lu" Date: Mon, 16 Aug 2021 15:02:37 -0700 Message-ID: Subject: Re: [PATCH v2] gdbserver: Check r_version < 1 for Linux debugger interface To: GNU C Library , GDB Cc: Simon Marchi Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-3031.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, 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: 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: , X-List-Received-Date: Mon, 16 Aug 2021 22:03:26 -0000 On Mon, Aug 16, 2021 at 1:30 PM H.J. Lu wrote: > > Update gdbserver to check r_version < 1 instead of r_version != 1 so > that r_version can be bumped for a new field in the glibc debugger > interface to support multiple namespaces. Since so far, the gdbserver > only reads fields defined for r_version == 1, it is compatible with > r_version >= 1. > > All future glibc debugger interface changes will be backward compatible. > If there is ever the need for backward incompatible change to the glibc > debugger interface, a new DT_XXX element will be provided to access the > new incompatible interface. > > PR gdb/11839 > * linux-low.cc (linux_process_target::qxfer_libraries_svr4): > Check r_version < 1 instead of r_version != 1. > --- > gdbserver/linux-low.cc | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc > index 5c6191d941c..fc7a995351d 100644 > --- a/gdbserver/linux-low.cc > +++ b/gdbserver/linux-low.cc > @@ -6845,7 +6845,7 @@ linux_process_target::qxfer_libraries_svr4 (const char *annex, > if (linux_read_memory (priv->r_debug + lmo->r_version_offset, > (unsigned char *) &r_version, > sizeof (r_version)) != 0 > - || r_version != 1) > + || r_version < 1) > { > warning ("unexpected r_debug version %d", r_version); > } > -- > 2.31.1 > Set r_version == 2 breaks GDB due to static CORE_ADDR solib_svr4_r_ldsomap (struct svr4_info *info) { struct link_map_offsets *lmo = svr4_fetch_link_map_offsets (); struct type *ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr; enum bfd_endian byte_order = type_byte_order (ptr_type); ULONGEST version = 0; try { /* Check version, and return zero if `struct r_debug' doesn't have the r_ldsomap member. */ version = read_memory_unsigned_integer (info->debug_base + lmo->r_version_offset, lmo->r_version_size, byte_order); } catch (const gdb_exception_error &ex) { exception_print (gdb_stderr, ex); } if (version < 2 || lmo->r_ldsomap_offset == -1) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ glibc doesn't have r_ldsomap. But r_ldsomap_offset is set unconditionally. Shouldn't it be set only if the target debugger interface has it? return 0; return read_memory_typed_address (info->debug_base + lmo->r_ldsomap_offset, ptr_type); } -- H.J.