From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by sourceware.org (Postfix) with ESMTPS id 2F66C3836E41 for ; Thu, 2 Jun 2022 14:28:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2F66C3836E41 X-IronPort-AV: E=McAfee;i="6400,9594,10365"; a="276039137" X-IronPort-AV: E=Sophos;i="5.91,271,1647327600"; d="scan'208";a="276039137" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2022 07:28:45 -0700 X-IronPort-AV: E=Sophos;i="5.91,271,1647327600"; d="scan'208";a="680666868" Received: from labpc2407.iul.intel.com (HELO localhost) ([172.28.50.61]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2022 07:28:44 -0700 From: Markus Metzger To: gdb-patches@sourceware.org Subject: [PATCH v5 00/15] basic linker namespace support Date: Thu, 2 Jun 2022 15:24:59 +0200 Message-Id: <20220602132514.957983-1-markus.t.metzger@intel.com> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Jun 2022 14:28:49 -0000 This series adds basic support for SVR4 linker namespaces. It makes GDB read DSOs from all namespaces and makes breakpoints bind in all namespaces. Symbol lookup (from debug info) is restricted to the namespace of the current location (expressed by the CURRENT_OBJFILE argument to gdbarch_iterate_over_objfiles_in_search_order) and defaults to the initial namespace. There are known issues (see below) and there are stil many places in GDB that iterate over objfiles and that are not aware of namespaces, including minimal symbol lookup. Since minimal symbol lookup is part of get_symbol_address (), we may accidentally overwrite a symbol that was resolved to an objfile in the correct namespace with one from a different namespace. I believe that get_symbol_address () should just return the address of that symbol, but then we need to find another way of handling copy relocations (see below). Namespaces are hidden in solib-svr4.c; the rest of GDB is not aware of them. Hence, they do not show up in 'info shared' or anywhere else on the user interface. Ben Woodard and Kevin Buettner requested namespaces to become part of the user interface to allow setting namespace-specific breakpoints or simply to show which libraries or breakpoint instances belong to which namespace. Lacking access to the namespace id that dlinfo(3) would provide, we use the address of the r_debug object as identifier and also pass it over RSP. The respective interface was defined as 'lmid', however, to allow changing it once we get access. The bulk of this series is changing direct objfiles iterations to use gdbarch_iterate_over_objfiles_in_search_order (). There are three cases that I did not handle and they are listed as known issues below. The rest, I either changed or convinced myself that it doesn't need changing. Expected fails: - gdb.base/non-lazy-array-index.exp: the expression parser may lookup global symbols, which may result in xfers to read auxv for determining the debug base as part of svr4_iterate_over_objfiles_in_search_order(). - gdb.server/non-lazy-array-index.exp: symbol lookup may access the target to read AUXV in order to determine the debug base for SVR4 linker namespaces. Known issues: - get_symbol_address() and get_msymbol_address() search objfiles for a 'better' match. This was introduced by 4b610737f02 Handle copy relocations to handle copy relocations but it now causes a wrong address to be read after symbol lookup actually found the correct symbol. This can be seen, for example, with gdb.base/dlmopen.exp when compiled with clang. - gnu ifuncs are only looked up in the initial namespace. - lookup_minimal_symbol() and lookup_minimal_symbol_text() directly iterate over objfiles and are not aware of linker namespaces. Regression-tested on x86-64 on a non-glibc-enabled system. The dlmopen part was tested (just gdb.base/dlmopen.exp) with an enabled glibc. The initial work was done by H.J. Lu. See also users/mmetzger/dlmopen. Markus Metzger (15): gdb, testsuite: extend gdb_test_multiple checks gdb, solib-svr4: remove locate_base() gdb, gdbserver: support dlmopen() gdbserver: move main_lm handling into caller gdb, gdbserver: extend RSP to support namespaces gdb, compile: unlink objfile stored in module gdb, python: use gdbarch_iterate_over_objfiles_in_search_order gdb, ada: collect standard exceptions in all objfiles gdb, ada: update ada_lookup_simple_minsym gdb, ada: update ada_add_all_symbols gdb, cp: update add_symbol_overload_list_qualified gdb, hppa: remove unused hppa_lookup_stub_minimal_symbol gdb, symtab: inline find_quick_global_symbol_language gdb: update gnu ifunc resolve gdb, solib-svr4: support namespaces in DSO iteration gdb/ada-exp.y | 9 +- gdb/ada-lang.c | 128 ++-- gdb/ada-lang.h | 3 +- gdb/compile/compile-object-run.c | 21 +- gdb/cp-support.c | 48 +- gdb/doc/gdb.texinfo | 16 +- gdb/elfread.c | 153 ++--- gdb/features/library-list-svr4.dtd | 4 + gdb/hppa-tdep.c | 31 - gdb/hppa-tdep.h | 4 - gdb/linux-tdep.c | 2 + gdb/mips-fbsd-tdep.c | 2 + gdb/mips-netbsd-tdep.c | 2 + gdb/python/py-objfile.c | 116 ++-- gdb/python/python.c | 7 +- gdb/python/python.h | 6 + gdb/solib-svr4.c | 553 +++++++++++++----- gdb/solib-svr4.h | 3 + gdb/symtab.c | 43 +- gdb/testsuite/gdb.base/dlmopen-lib-dep.c | 21 + gdb/testsuite/gdb.base/dlmopen-lib.c | 28 + gdb/testsuite/gdb.base/dlmopen.c | 65 ++ gdb/testsuite/gdb.base/dlmopen.exp | 174 ++++++ .../gdb.base/non-lazy-array-index.exp | 18 +- .../gdb.server/bkpt-other-inferior.exp | 13 +- gdb/testsuite/lib/gdb.exp | 108 ++++ gdbserver/linux-low.cc | 273 +++++---- 27 files changed, 1324 insertions(+), 527 deletions(-) create mode 100644 gdb/testsuite/gdb.base/dlmopen-lib-dep.c create mode 100644 gdb/testsuite/gdb.base/dlmopen-lib.c create mode 100644 gdb/testsuite/gdb.base/dlmopen.c create mode 100644 gdb/testsuite/gdb.base/dlmopen.exp -- 2.35.3 Intel Deutschland GmbH Registered Address: Am Campeon 10, 85579 Neubiberg, Germany Tel: +49 89 99 8853-0, www.intel.de Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva Chairperson of the Supervisory Board: Nicole Lau Registered Office: Munich Commercial Register: Amtsgericht Muenchen HRB 186928