From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id MMiUJ1Oc6mGWQgAAWB0awg (envelope-from ) for ; Fri, 21 Jan 2022 06:43:15 -0500 Received: by simark.ca (Postfix, from userid 112) id 9F4181F3B6; Fri, 21 Jan 2022 06:43:15 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_DYNAMIC,URIBL_BLOCKED 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 (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id B43131F0BB for ; Fri, 21 Jan 2022 06:43:13 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 597CB3857816 for ; Fri, 21 Jan 2022 11:43:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 597CB3857816 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1642765393; bh=a/rSpSpnYxXdKbsGmGcj7w0Q9yZlibLZYK7YNPc9Xuk=; h=To:Subject:Date:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=A/F8oxoDWiUMDGADpIdwMGs9q+RAG4DuNypEgg2Jp8radvAD2Ys+F0voD1jkQJ1yA locm049bxa+JMiqPSQfz2TcHG1P/xlMbTTT4pRWH6L+Dg0h0IPThXLpI1tp5MhUSCY 1YeyfukH3ANffRGP5bpugJTWej12FKZEnSewS7Zg= Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by sourceware.org (Postfix) with ESMTPS id 5F4C03858C2C for ; Fri, 21 Jan 2022 11:42:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5F4C03858C2C X-IronPort-AV: E=McAfee;i="6200,9189,10233"; a="226311555" X-IronPort-AV: E=Sophos;i="5.88,304,1635231600"; d="scan'208";a="226311555" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jan 2022 03:42:49 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,304,1635231600"; d="scan'208";a="493821326" Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16]) by orsmga002.jf.intel.com with ESMTP; 21 Jan 2022 03:42:49 -0800 Received: from orsmsx608.amr.corp.intel.com (10.22.229.21) by ORSMSX603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Fri, 21 Jan 2022 03:42:49 -0800 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) by orsmsx608.amr.corp.intel.com (10.22.229.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20 via Frontend Transport; Fri, 21 Jan 2022 03:42:49 -0800 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (104.47.59.174) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.20; Fri, 21 Jan 2022 03:42:48 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YKiFDNhpFPcR0wM+wpieo9A5uQpDos87E7EzF/tTACzuoAnTgiDwUxe8VxDDVPWvrGjKexiXFIOduY4V61PwwYeONsoAja3gSfztWk8nNk68283xwe2dRwxATRchiEI9HkwALDVuE1fKZ1g/an9shMwiOljUS8SZ9ZrJ0lxnJrtYjr1xlsdIz+YWYc/+/Gc/vzgc37/V0kIrH2QEwuT8Prya8DswxEvRfg6AclY9z6iCImlhZGxoug5KDfgOCjwzVcENlHkcCQ98D/9nvl7Hav7E0wh916dil9qNyz9pS15Hu5BSaKa52sWniOriSJgOMJkGgObfIAs1nzspjnIFNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=esG2gUcFatZCwNMHY6LhslfTbLV6AQKOS+TcSGAmLJM=; b=kqQFUOShyczrvoKZ/s1vnC8Itwix6J7fyZTQqg3uXGM836lkDq4dC+6KXmgtr+Bd/Z+fiFf2X41fM+q0Hx+70n/Mf/a/Rv5SaKHjtkl2VOkh21my9ImmRTrJ5hg+OOhtpKDtKb0SolsZTy1MxjfE+RffmCYhuCur4fr+eCItxt6KGMgUBJoXIYhiRGxd4fbyB9d96cgd9JKYxZyzTC5WP41j3watjNIr31Sw+pUbqutIf7t/c8wf+VjfpIkQAEcX5SXX7K/hL/naHjKVMH5FVbur4s7jIUghijokYeeGEVVS9+X1bXLwg/zCl+MJ+xnj+RAph4AiGfPHio9zk1d7WQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Received: from DM8PR11MB5749.namprd11.prod.outlook.com (2603:10b6:8:10::15) by CO1PR11MB5059.namprd11.prod.outlook.com (2603:10b6:303:9a::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4909.7; Fri, 21 Jan 2022 11:42:46 +0000 Received: from DM8PR11MB5749.namprd11.prod.outlook.com ([fe80::9068:e388:7f75:c3b8]) by DM8PR11MB5749.namprd11.prod.outlook.com ([fe80::9068:e388:7f75:c3b8%8]) with mapi id 15.20.4909.012; Fri, 21 Jan 2022 11:42:46 +0000 To: "gdb-patches@sourceware.org" Subject: RE: [PATCH v4] gdb, gdbserver: support dlmopen() Thread-Topic: [PATCH v4] gdb, gdbserver: support dlmopen() Thread-Index: AQHX27+g14KH1lzgikK5e/1QZuBpxqxtwHbw Date: Fri, 21 Jan 2022 11:42:46 +0000 Message-ID: References: <20211117142812.3685162-1-markus.t.metzger@intel.com> In-Reply-To: <20211117142812.3685162-1-markus.t.metzger@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 848ac759-7491-42dd-7415-08d9dcd324db x-ms-traffictypediagnostic: CO1PR11MB5059:EE_ x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:4125; x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: l0YcSd+uS7OTuYK2HCSHYaHp47IKRFSGO54S7Ifn+i9vonDZgCG4abQbWoFgQlmu5KtDJJTx7V0UM2mRpC6bTyCZiC6ydsleeT4A5IcDms6m5l1iLQkmG3miLKNxjT887ff+N8ddC0ujou+uxj0WTRM2brP1HlCzQKE4K3JFAqFbQoc5pWe4j8cGlMviuQq8FvDXvx1jkRFOTD0o2+ZlHoyFI1RTvrwUFn8/XNLiM+rsFQIoXw5m5NqrRKgrpe/I0jPQFsiFw2B6ZReO0ng/kPEoXqLHAPvlyN8bm2o2ohYMI3Va3NfpjhNRFxj+/rDldxiviVA7Fhja/P2QwZytsFVlKuw+AzMsQudoI9KBhanwEIpM0ZL54+P3CoZPJlsZoZa6AlFp5ueOSZxor6Yt0LlN/GjoeFMtouNNeJ3MPdX5TH6YcOxxTCyA0SnBWViNdvfdg54bLdjr8BWETzk1W1XB4NVmvUNmt/Jbb+szMgG/xmRBFf2pU9PI5rKaQ+nN0TUbS2Q3eDmbmVgZnG0/rPH3XZU95/G4ouCb8u/euoZQ/cwCnwJiMWZy4qPsrOEOpsNngUxj0CUE/X44mgxSWia8zyZF9h03l8APVUP8kmg+f/xlsBkTYKVmpbd39umgQjagxsJrIZejG+8+Rp7SZ7lAcS/V4+uXVN1K7egsSz1w09YYDiPE9rl6kUi1Oph355YvrcVQZoRlm/rVdb1pt9KReVymM7W41pnpo1F/W94A62MJybTVjC4wA3sxClQKhoLw10h8sTrUPBkVx6L8U+ZcbqB4X03Oq9KjqdmOvQoApgSg8DDzeOZYBoZVx3wC x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM8PR11MB5749.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(366004)(5660300002)(316002)(33656002)(52536014)(84970400001)(122000001)(66446008)(66946007)(66476007)(64756008)(66556008)(38100700002)(6506007)(186003)(2906002)(55016003)(76116006)(86362001)(7696005)(508600001)(9686003)(82960400001)(6916009)(71200400001)(8936002)(83380400001)(30864003)(38070700005)(8676002)(26005)(2004002)(559001)(579004); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?YdNpnSAILfbwim/jT1pqmSa3IX1ySMiUyQYfKqTTaKLYTIDitzQO7W/PeSZO?= =?us-ascii?Q?iSh8f7m/qtiBK2z5sPGymkaMkAfJfyx/xz+D7uUOEc/69WUdOa2YyOaYgA0/?= =?us-ascii?Q?76n1eTDpUEZP37tYMDWbh7OvebTh0yEcWzmjJujcgWFH9SNbovfCXLWiXQ01?= =?us-ascii?Q?gmed85u/Fny3nnNZ7PvNHc+Cbw1qE04Dvs1I1IVKqbSov+mnRcNi1TnMbqeM?= =?us-ascii?Q?ZoPjiML7d2OZQBOsqEXTimpNBolXRnhShImTVfDTR/qsCeust2+LLrU5SFrs?= =?us-ascii?Q?RJzKYFCPql20hVCbTSUDr3nodB7rBaB06NymGjsyJDdQbKP0x6Z49vY8A5DP?= =?us-ascii?Q?VSLvdIUT1sbKXivPsDNwfUmRFlUVBmZnrSlaMyZ1iqf6kGN7zVRwU52M5eBj?= =?us-ascii?Q?XpK7MHgxocUy0I1iDFOV7BCZw2DMfjfzSaty19wI8CA3yzjP5CWS4qMKh3ru?= =?us-ascii?Q?x/Sz2xPhbTss+3Fl+m3Krjp+W7dDuItsGHZYsGOOdoTeWYVUvwVNfTt1utLb?= =?us-ascii?Q?znm2jmrACgmk1xdaprYnuP3ZhqWlouZkmse8g6Dhh1DFcsOMLeTAW0ymqi7x?= =?us-ascii?Q?l22So7zxwQtc1u7ttdVcHHkQ2lDF6RhHnh3CxOD6DLEdsc9UAfgXrRZ2QkCW?= =?us-ascii?Q?KyKfAjjfR9f26JPUbg/d6RYsZausSmpZfV644QqVPOxDqGHMkEvetKQ4ke+8?= =?us-ascii?Q?B0u1Hd/f2+KL6UA6SdNtAdBAD84wOazpkb2JwNVr7x99L483XM1Lc2I5Cmi3?= =?us-ascii?Q?jP9L36/x4va9w1cmswXV/wvaTUETYrhvjGXuawVfRZbVJDwJZI9MCWOpa7T7?= =?us-ascii?Q?3bdgYIO2X8RP2x4VGW1rd4lopCx4G0oMGN6nPsBvWpMWXMrQv2W8+EYo/kl6?= =?us-ascii?Q?fPmRyJ4tVn5J7uxGBBIdCh2rceofxMaqCCrOAEkWH+Tv2EP9JMduWo4yAoFZ?= =?us-ascii?Q?Tiv/c8WAIgG38zYNoZ0CYnIzMYGWqWWbPJI3m8sNnbDGq/9o9olusLSspLCY?= =?us-ascii?Q?LzbUDpGqZZLMPsAmY1OCR6LE0dcyFqgMVNAh0ArxpS8AKzESGO9agluK24Dc?= =?us-ascii?Q?A3gBQpcfvi/VQS0YWPcKZIkat3+1w4NyXvrciKiQQufWFB6EvcUXJOcJ9qVP?= =?us-ascii?Q?R6lXgI1AFNvGUl8gfDyOyEji7Ef5zSvwBQqPMfAS6Ptoke/zunWBRoTW7dly?= =?us-ascii?Q?Hs31On8DZDzNPY2PHgkNckDA6YUnakF3qKxhmOCY62fL0z08DL4GEgit5Ecy?= =?us-ascii?Q?pMyLJ8xe6aQUk9O+2OqDif2vYsyChIR3wihXAZ+iukOG5Lut/5onWMvVopfw?= =?us-ascii?Q?tvcSqL3Rs4HyrBAYA1DaxmxiZIxHbz3g6b3EiPWKEMO3kT3FDEjX7IUrRWnC?= =?us-ascii?Q?djYBoj75NLAnERyRcVc4WG5Fi9Dv1PplBwJ+y4J4i1st8yMkNMYHxx6mEu3S?= =?us-ascii?Q?XZt01e6+mQiGn3A5KOCr1ETOPouDtN2CaB9izoYs16jB8AdR4vDUaFQ1Q72u?= =?us-ascii?Q?TEQ3TCyYhNexcRKYujYl/oKcbOeO4xURF3J1Ob2xtfvqX/UTiUhrWYCClRPO?= =?us-ascii?Q?kV4kw+TpLXVMgJbx5BSNF1wuPxi/jUSyA1XSdN47yjYlY+uZWj9tbDj5MvTF?= =?us-ascii?Q?NIHR/hwzbq0loA8pmxr1tFcq4DKj1M1H3FCZxTcJiiWY0M/YqNktOQkNJLAH?= =?us-ascii?Q?N+brSQ=3D=3D?= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM8PR11MB5749.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 848ac759-7491-42dd-7415-08d9dcd324db X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Jan 2022 11:42:46.2958 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: pgfHGUk2j/jj7Pmk8Gil4nuXTQvKuUKP+iBdZJfJUmWe1oCfNHkEKR2n5mGinDvKqURatt5/dpQcEb1KZjsVLXslji3knPmzDVbZhoHfYk4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR11MB5059 X-OriginatorOrg: intel.com Content-Transfer-Encoding: quoted-printable 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: , From: "Metzger, Markus T via Gdb-patches" Reply-To: "Metzger, Markus T" Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" Kindly pinging, Markus. >-----Original Message----- >From: Metzger, Markus T >Sent: Wednesday, November 17, 2021 3:28 PM >To: gdb-patches@sourceware.org >Subject: [PATCH v4] gdb, gdbserver: support dlmopen() > >This patch was originally developed by H.J. Last version: >https://sourceware.org/pipermail/gdb-patches/2021-October/182353.html > >Changes in v4: > >1. add gdb.base/dlmopen.exp >2. extend svr4_same() to compare the load offset in addition to the name >3. supply l_addr_inferior for default DSO to make it work with #2 >4. fix bugs in gdbserver/linux-low.cc > >Changes in v3: > >1. Fix gdbserver support. > >Changes in v2: > >1. Don't check shared libraries in other namespaces when updating shared >libraries in a new namespace. > >Regression-tested on x86-64 linux. > >--- > >In glibc, the r_debug structure contains (amongst others) the following >fields: > > int r_version: > Version number for this protocol. It should be greater than 0. > >If r_version is 2, struct r_debug is extended to struct r_debug_extended >with one additional field: > > struct r_debug_extended *r_next; > Link to the next r_debug_extended structure. Each r_debug_extended > structure represents a different namespace. The first r_debug_extended > structure is for the default namespace. > >1. Change solib_svr4_r_map argument to take the debug base. >2. Add solib_svr4_r_next to find the link map in the next namespace from >the r_next field. >3. Update svr4_current_sos_direct to get the link map in the next namespace >from the r_next field. >4. Don't check shared libraries in other namespaces when updating shared >libraries in a new namespace. >5. Update svr4_same to check the load offset in addition to the name >6. Update svr4_default_sos to also set l_addr_inferior > >Add gdb.base/dlmopen.exp to test this. > >This fixes PR 11839. >--- > gdb/linux-tdep.c | 2 + > gdb/mips-fbsd-tdep.c | 2 + > gdb/mips-netbsd-tdep.c | 2 + > gdb/solib-svr4.c | 89 ++++++++-- > gdb/solib-svr4.h | 3 + > gdb/testsuite/gdb.base/dlmopen-lib.c | 25 +++ > gdb/testsuite/gdb.base/dlmopen.c | 56 +++++++ > gdb/testsuite/gdb.base/dlmopen.exp | 141 ++++++++++++++++ > gdbserver/linux-low.cc | 242 ++++++++++++++++----------- > 9 files changed, 450 insertions(+), 112 deletions(-) > 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 > >diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c >index e2cff83086a..cb8e52d760a 100644 >--- a/gdb/linux-tdep.c >+++ b/gdb/linux-tdep.c >@@ -2739,6 +2739,7 @@ linux_ilp32_fetch_link_map_offsets () > lmo.r_map_offset =3D 4; > lmo.r_brk_offset =3D 8; > lmo.r_ldsomap_offset =3D -1; >+ lmo.r_next_offset =3D 20; > > /* Everything we need is in the first 20 bytes. */ > lmo.link_map_size =3D 20; >@@ -2767,6 +2768,7 @@ linux_lp64_fetch_link_map_offsets () > lmo.r_map_offset =3D 8; > lmo.r_brk_offset =3D 16; > lmo.r_ldsomap_offset =3D -1; >+ lmo.r_next_offset =3D 40; > > /* Everything we need is in the first 40 bytes. */ > lmo.link_map_size =3D 40; >diff --git a/gdb/mips-fbsd-tdep.c b/gdb/mips-fbsd-tdep.c >index 0b7c97c445f..00e38a8f1c4 100644 >--- a/gdb/mips-fbsd-tdep.c >+++ b/gdb/mips-fbsd-tdep.c >@@ -495,6 +495,7 @@ mips_fbsd_ilp32_fetch_link_map_offsets (void) > lmo.r_map_offset =3D 4; > lmo.r_brk_offset =3D 8; > lmo.r_ldsomap_offset =3D -1; >+ lmo.r_next_offset =3D -1; > > lmo.link_map_size =3D 24; > lmo.l_addr_offset =3D 0; >@@ -522,6 +523,7 @@ mips_fbsd_lp64_fetch_link_map_offsets (void) > lmo.r_map_offset =3D 8; > lmo.r_brk_offset =3D 16; > lmo.r_ldsomap_offset =3D -1; >+ lmo.r_next_offset =3D -1; > > lmo.link_map_size =3D 48; > lmo.l_addr_offset =3D 0; >diff --git a/gdb/mips-netbsd-tdep.c b/gdb/mips-netbsd-tdep.c >index a32ae5e3a29..12d702ef359 100644 >--- a/gdb/mips-netbsd-tdep.c >+++ b/gdb/mips-netbsd-tdep.c >@@ -308,6 +308,7 @@ mipsnbsd_ilp32_fetch_link_map_offsets (void) > lmo.r_map_offset =3D 4; > lmo.r_brk_offset =3D 8; > lmo.r_ldsomap_offset =3D -1; >+ lmo.r_next_offset =3D -1; > > /* Everything we need is in the first 24 bytes. */ > lmo.link_map_size =3D 24; >@@ -336,6 +337,7 @@ mipsnbsd_lp64_fetch_link_map_offsets (void) > lmo.r_map_offset =3D 8; > lmo.r_brk_offset =3D 16; > lmo.r_ldsomap_offset =3D -1; >+ lmo.r_next_offset =3D -1; > > /* Everything we need is in the first 40 bytes. */ > lmo.link_map_size =3D 48; >diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c >index 3de1bb9c7f7..d57a3c1ffdb 100644 >--- a/gdb/solib-svr4.c >+++ b/gdb/solib-svr4.c >@@ -174,7 +174,16 @@ svr4_same_1 (const char *gdb_so_name, const char >*inferior_so_name) > static int > svr4_same (struct so_list *gdb, struct so_list *inferior) > { >- return (svr4_same_1 (gdb->so_original_name, inferior->so_original_name)= ); >+ if (!svr4_same_1 (gdb->so_original_name, inferior->so_original_name)) >+ return false; >+ >+ /* There may be different instances of the same library, in different >+ namespaces. Each instance, however, must have been loaded at a >+ different address so its relocation offset would be different. */ >+ const lm_info_svr4 *lmg =3D (const lm_info_svr4 *) gdb->lm_info; >+ const lm_info_svr4 *lmi =3D (const lm_info_svr4 *) inferior->lm_info; >+ >+ return (lmg->l_addr_inferior =3D=3D lmi->l_addr_inferior); > } > > static std::unique_ptr >@@ -767,7 +776,7 @@ locate_base (struct svr4_info *info) > RT_CONSISTENT. */ > > static CORE_ADDR >-solib_svr4_r_map (struct svr4_info *info) >+solib_svr4_r_map (CORE_ADDR debug_base) > { > struct link_map_offsets *lmo =3D svr4_fetch_link_map_offsets (); > struct type *ptr_type =3D builtin_type (target_gdbarch ())->builtin_dat= a_ptr; >@@ -775,7 +784,7 @@ solib_svr4_r_map (struct svr4_info *info) > > try > { >- addr =3D read_memory_typed_address (info->debug_base + lmo- >>r_map_offset, >+ addr =3D read_memory_typed_address (debug_base + lmo->r_map_offset, > ptr_type); > } > catch (const gdb_exception_error &ex) >@@ -829,6 +838,35 @@ solib_svr4_r_ldsomap (struct svr4_info *info) > ptr_type); > } > >+/* Find the next namespace from the r_next field. */ >+ >+static CORE_ADDR >+solib_svr4_r_next (CORE_ADDR debug_base) >+{ >+ struct link_map_offsets *lmo =3D svr4_fetch_link_map_offsets (); >+ struct type *ptr_type =3D builtin_type (target_gdbarch ())->builtin_dat= a_ptr; >+ enum bfd_endian byte_order =3D type_byte_order (ptr_type); >+ ULONGEST version =3D 0; >+ >+ try >+ { >+ version >+ =3D read_memory_unsigned_integer (debug_base + lmo->r_version_offset, >+ lmo->r_version_size, byte_order); >+ } >+ catch (const gdb_exception_error &ex) >+ { >+ exception_print (gdb_stderr, ex); >+ } >+ >+ /* The r_next field is added with r_version =3D=3D 2. */ >+ if (version < 2 || lmo->r_next_offset =3D=3D -1) >+ return 0; >+ >+ return read_memory_typed_address (debug_base + lmo->r_next_offset, >+ ptr_type); >+} >+ > /* On Solaris systems with some versions of the dynamic linker, > ld.so's l_name pointer points to the SONAME in the string table > rather than into writable memory. So that GDB can find shared >@@ -886,7 +924,7 @@ open_symbol_file_object (int from_tty) > return 0; /* failed somehow... */ > > /* First link map member should be the executable. */ >- lm =3D solib_svr4_r_map (info); >+ lm =3D solib_svr4_r_map (info->debug_base); > if (lm =3D=3D 0) > return 0; /* failed somehow... */ > >@@ -1178,7 +1216,7 @@ svr4_default_sos (svr4_info *info) > newobj->lm_info =3D li; > > /* Nothing will ever check the other fields if we set l_addr_p. */ >- li->l_addr =3D info->debug_loader_offset; >+ li->l_addr =3D li->l_addr_inferior =3D info->debug_loader_offset; > li->l_addr_p =3D 1; > > strncpy (newobj->so_name, info->debug_loader_name, >SO_NAME_MAX_PATH_SIZE - 1); >@@ -1323,7 +1361,7 @@ svr4_current_sos_direct (struct svr4_info *info) > > /* Walk the inferior's link map list, and build our list of > `struct so_list' nodes. */ >- lm =3D solib_svr4_r_map (info); >+ lm =3D solib_svr4_r_map (info->debug_base); > if (lm) > svr4_read_so_list (info, lm, 0, &link_ptr, ignore_first); > >@@ -1335,6 +1373,18 @@ svr4_current_sos_direct (struct svr4_info *info) > if (lm) > svr4_read_so_list (info, lm, 0, &link_ptr, 0); > >+ /* Get the next namespace from the r_next field. */ >+ lm =3D solib_svr4_r_next (info->debug_base); >+ while (lm !=3D 0) >+ { >+ /* Get the link map in this namespace. */ >+ CORE_ADDR link_map =3D solib_svr4_r_map (lm); >+ if (link_map !=3D 0) >+ svr4_read_so_list (info, link_map, 0, &link_ptr, 0); >+ /* Go to the next namespace. */ >+ lm =3D solib_svr4_r_next (lm); >+ } >+ > cleanup.release (); > > if (head =3D=3D NULL) >@@ -1706,7 +1756,8 @@ solist_update_full (struct svr4_info *info) > failure. */ > > static int >-solist_update_incremental (struct svr4_info *info, CORE_ADDR lm) >+solist_update_incremental (struct svr4_info *info, CORE_ADDR debug_base, >+ CORE_ADDR lm) > { > struct so_list *tail; > CORE_ADDR prev_lm; >@@ -1727,8 +1778,15 @@ solist_update_incremental (struct svr4_info *info, >CORE_ADDR lm) > for (tail =3D info->solib_list; tail->next !=3D NULL; tail =3D tail->ne= xt) > /* Nothing. */; > >- lm_info_svr4 *li =3D (lm_info_svr4 *) tail->lm_info; >- prev_lm =3D li->lm_addr; >+ /* Don't check shared libraries in other namespaces when updating >+ shared libraries in a new namespace. */ >+ if (debug_base =3D=3D info->debug_base) >+ { >+ lm_info_svr4 *li =3D (lm_info_svr4 *) tail->lm_info; >+ prev_lm =3D li->lm_addr; >+ } >+ else >+ prev_lm =3D 0; > > /* Read the new objects. */ > if (info->using_xfer) >@@ -1869,13 +1927,6 @@ svr4_handle_solib_event (void) > return; > } > >- /* GDB does not currently support libraries loaded via dlmopen >- into namespaces other than the initial one. We must ignore >- any namespace other than the initial namespace here until >- support for this is added to GDB. */ >- if (debug_base !=3D info->debug_base) >- action =3D DO_NOTHING; >- > if (action =3D=3D UPDATE_OR_RELOAD) > { > try >@@ -1901,7 +1952,7 @@ svr4_handle_solib_event (void) > > if (action =3D=3D UPDATE_OR_RELOAD) > { >- if (!solist_update_incremental (info, lm)) >+ if (!solist_update_incremental (info, debug_base, lm)) > action =3D FULL_RELOAD; > } > >@@ -2136,7 +2187,7 @@ enable_break (struct svr4_info *info, int from_tty) > > solib_add (NULL, from_tty, auto_solib_add); > sym_addr =3D 0; >- if (info->debug_base && solib_svr4_r_map (info) !=3D 0) >+ if (info->debug_base && solib_svr4_r_map (info->debug_base) !=3D 0) > sym_addr =3D solib_svr4_r_brk (info); > > if (sym_addr !=3D 0) >@@ -3087,6 +3138,7 @@ svr4_ilp32_fetch_link_map_offsets (void) > lmo.r_map_offset =3D 4; > lmo.r_brk_offset =3D 8; > lmo.r_ldsomap_offset =3D 20; >+ lmo.r_next_offset =3D -1; > > /* Everything we need is in the first 20 bytes. */ > lmo.link_map_size =3D 20; >@@ -3118,6 +3170,7 @@ svr4_lp64_fetch_link_map_offsets (void) > lmo.r_map_offset =3D 8; > lmo.r_brk_offset =3D 16; > lmo.r_ldsomap_offset =3D 40; >+ lmo.r_next_offset =3D -1; > > /* Everything we need is in the first 40 bytes. */ > lmo.link_map_size =3D 40; >diff --git a/gdb/solib-svr4.h b/gdb/solib-svr4.h >index 8d94d9cb26e..64854e2edd9 100644 >--- a/gdb/solib-svr4.h >+++ b/gdb/solib-svr4.h >@@ -66,6 +66,9 @@ struct link_map_offsets > /* Offset of r_debug.r_ldsomap. */ > int r_ldsomap_offset; > >+ /* Offset of r_debug_extended.r_next. */ >+ int r_next_offset; >+ > /* Size of struct link_map (or equivalent), or at least enough of it > to be able to obtain the fields below. */ > int link_map_size; >diff --git a/gdb/testsuite/gdb.base/dlmopen-lib.c >b/gdb/testsuite/gdb.base/dlmopen-lib.c >new file mode 100644 >index 00000000000..264659ec9de >--- /dev/null >+++ b/gdb/testsuite/gdb.base/dlmopen-lib.c >@@ -0,0 +1,25 @@ >+/* This testcase is part of GDB, the GNU debugger. >+ >+ Copyright 2021 Free Software Foundation, Inc. >+ >+ This program is free software; you can redistribute it and/or modify >+ it under the terms of the GNU General Public License as published by >+ the Free Software Foundation; either version 3 of the License, or >+ (at your option) any later version. >+ >+ This program is distributed in the hope that it will be useful, >+ but WITHOUT ANY WARRANTY; without even the implied warranty of >+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+ GNU General Public License for more details. >+ >+ You should have received a copy of the GNU General Public License >+ along with this program. If not, see . >+ >+*/ >+ >+__attribute__((visibility ("default"))) >+int >+inc (int n) >+{ >+ return n + 1; /* bp.inc. */ >+} >diff --git a/gdb/testsuite/gdb.base/dlmopen.c >b/gdb/testsuite/gdb.base/dlmopen.c >new file mode 100644 >index 00000000000..49040dc8738 >--- /dev/null >+++ b/gdb/testsuite/gdb.base/dlmopen.c >@@ -0,0 +1,56 @@ >+/* This testcase is part of GDB, the GNU debugger. >+ >+ Copyright 2021 Free Software Foundation, Inc. >+ >+ This program is free software; you can redistribute it and/or modify >+ it under the terms of the GNU General Public License as published by >+ the Free Software Foundation; either version 3 of the License, or >+ (at your option) any later version. >+ >+ This program is distributed in the hope that it will be useful, >+ but WITHOUT ANY WARRANTY; without even the implied warranty of >+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+ GNU General Public License for more details. >+ >+ You should have received a copy of the GNU General Public License >+ along with this program. If not, see . >+ >+*/ >+ >+#define _GNU_SOURCE >+#include >+#include >+#include >+ >+volatile int pause =3D 1; >+ >+int >+main (void) >+{ >+ void *handle[2]; >+ int (*fun) (int); >+ >+ handle[0] =3D dlmopen (LM_ID_NEWLM, DSO_NAME, RTLD_LAZY | RTLD_LOCAL); >+ assert (handle[0] !=3D NULL); >+ >+ handle[1] =3D dlmopen (LM_ID_NEWLM, DSO_NAME, RTLD_LAZY | RTLD_LOCAL); >+ assert (handle[1] !=3D NULL); >+ >+ fun =3D dlsym (handle[0], "inc"); >+ assert (fun !=3D NULL); >+ >+ while (pause !=3D 0) >+ ; >+ >+ fun (42); >+ >+ dlclose (handle[0]); >+ >+ fun =3D dlsym (handle[1], "inc"); >+ assert (fun !=3D NULL); >+ >+ fun (42); >+ >+ dlclose (handle[1]); >+ return 0; /* bp.main */ >+} >diff --git a/gdb/testsuite/gdb.base/dlmopen.exp >b/gdb/testsuite/gdb.base/dlmopen.exp >new file mode 100644 >index 00000000000..fbf6fcb6b42 >--- /dev/null >+++ b/gdb/testsuite/gdb.base/dlmopen.exp >@@ -0,0 +1,141 @@ >+# This testcase is part of GDB, the GNU debugger. >+# >+# Copyright 2021 Free Software Foundation, Inc. >+# >+# This program is free software; you can redistribute it and/or modify >+# it under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# This program is distributed in the hope that it will be useful, >+# but WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with this program. If not, see . >+ >+if { [skip_shlib_tests] } { >+ unsupported "target does not support dynamic libraries" >+ return -1 >+} >+ >+standard_testfile >+ >+set basename_lib dlmopen-lib >+set srcfile_lib $srcdir/$subdir/$basename_lib.c >+set binfile_lib [standard_output_file $basename_lib.so] >+ >+if { [gdb_compile_shlib $srcfile_lib $binfile_lib {debug}] !=3D "" } { >+ untested "failed to prepare shlib" >+ return -1 >+} >+ >+if { [prepare_for_testing "failed to prepare" $testfile $srcfile \ >+ [list additional_flags=3D-DDSO_NAME=3D\"$binfile_lib\" \ >+ libs=3D-ldl debug]] } { >+ return -1 >+} >+ >+if { ![runto_main] } { >+ return -1 >+} >+ >+# Check that 'info shared' show NUM occurrences of DSO. >+proc check_dso_count { dso num } { >+ global gdb_prompt >+ >+ set count 0 >+ gdb_test_multiple "info shared" "info shared" { >+ -re "$dso" { >+ set count [expr $count + 1] >+ exp_continue >+ } >+ -re "$gdb_prompt " { >+ gdb_assert {$count =3D=3D $num} $gdb_test_name >+ } >+ } >+} >+ >+# The actual test. We run it twice. >+proc test_dlmopen {} { >+ global srcfile srcfile_lib binfile_lib bp_main bp_inc >+ >+ with_test_prefix "dso 1" { >+ # Try to reach the breakpoint in the dynamically loaded library. >+ gdb_continue_to_breakpoint "cont to bp.inc" \ >+ ".*$srcfile_lib:$bp_inc\r\n.*" >+ >+ # The library should be listed twice. >+ check_dso_count $binfile_lib 2 >+ >+ # This might help debugging. >+ gdb_test "info breakpoints" ".*" >+ gdb_test "print \$pc" ".*" >+ } >+ >+ with_test_prefix "dso 2" { >+ # Try to reach the breakpoint in the dynamically loaded library. >+ gdb_continue_to_breakpoint "cont to bp.inc" \ >+ ".*$srcfile_lib:$bp_inc\r\n.*" >+ >+ # The library should be listed once. >+ check_dso_count $binfile_lib 1 >+ >+ # This might help debugging. >+ gdb_test "info breakpoints" ".*" >+ gdb_test "print \$pc" ".*" >+ } >+ >+ with_test_prefix "main" { >+ # Try to reach the breakpoint in the dynamically loaded library. >+ gdb_continue_to_breakpoint "cont to bp.main" \ >+ ".*$srcfile:$bp_main\r\n.*" >+ >+ # The library should not be listed. >+ check_dso_count $binfile_lib 0 >+ } >+} >+ >+# Remove the pause. We only need it for the attach test. >+gdb_test "print pause =3D 0" "\\\$1 =3D 0" >+ >+# The library is not yet loaded. We need breakpoints to be pending. >+gdb_test_no_output "set breakpoint pending on" >+ >+# Break in the to-be-loaded library and at the end of main. >+set bp_inc [gdb_get_line_number "bp.inc" $srcfile_lib] >+set bp_main [gdb_get_line_number "bp.main" $srcfile] >+ >+delete_breakpoints >+gdb_breakpoint $srcfile_lib:$bp_inc allow-pending >+gdb_breakpoint $srcfile:$bp_main >+ >+test_dlmopen >+ >+# Try the same again when attaching after dlmopen(). >+if { ![can_spawn_for_attach] } { >+ unsupported "target does not support attach" >+ return -1 >+} >+ >+clean_restart $binfile >+ >+# Start the test program. >+set test_spawn_id [spawn_wait_for_attach $binfile] >+set testpid [spawn_id_get_pid $test_spawn_id] >+ >+# Attach. >+gdb_test "attach $testpid" "Attaching to program.*, process $testpid.*" >+ >+with_test_prefix "attach" { >+ # Remove the pause. We no longer need it. >+ gdb_test "print pause =3D 0" "\\\$1 =3D 0" >+ >+ # Set the same breakpoints again. This time, however, we do not allo= w the >+ # breakpoint to be pending since the library has already been loaded. >+ gdb_breakpoint $srcfile_lib:$bp_inc >+ gdb_breakpoint $srcfile:$bp_main >+ >+ test_dlmopen >+} >diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc >index 34ede238d19..4ad0f94526d 100644 >--- a/gdbserver/linux-low.cc >+++ b/gdbserver/linux-low.cc >@@ -6727,6 +6727,9 @@ struct link_map_offsets > /* Offset and size of r_debug.r_map. */ > int r_map_offset; > >+ /* Offset of r_debug_extended.r_next. */ >+ int r_next_offset; >+ > /* Offset to l_addr field in struct link_map. */ > int l_addr_offset; > >@@ -6743,6 +6746,98 @@ struct link_map_offsets > int l_prev_offset; > }; > >+static const struct link_map_offsets lmo_32bit_offsets =3D >+ { >+ 0, /* r_version offset. */ >+ 4, /* r_debug.r_map offset. */ >+ 20, /* r_debug_extended.r_next. */ >+ 0, /* l_addr offset in link_map. */ >+ 4, /* l_name offset in link_map. */ >+ 8, /* l_ld offset in link_map. */ >+ 12, /* l_next offset in link_map. */ >+ 16 /* l_prev offset in link_map. */ >+ }; >+ >+static const struct link_map_offsets lmo_64bit_offsets =3D >+ { >+ 0, /* r_version offset. */ >+ 8, /* r_debug.r_map offset. */ >+ 40, /* r_debug_extended.r_next. */ >+ 0, /* l_addr offset in link_map. */ >+ 8, /* l_name offset in link_map. */ >+ 16, /* l_ld offset in link_map. */ >+ 24, /* l_next offset in link_map. */ >+ 32 /* l_prev offset in link_map. */ >+ }; >+ >+/* Get the loaded shared libraries from one namespace. */ >+ >+static void >+read_link_map (std::string &document, CORE_ADDR lm_addr, CORE_ADDR >lm_prev, >+ int ptr_size, const struct link_map_offsets *lmo, >+ bool ignore_first, int &header_done) >+{ >+ CORE_ADDR l_name, l_addr, l_ld, l_next, l_prev; >+ >+ while (lm_addr >+ && read_one_ptr (lm_addr + lmo->l_name_offset, >+ &l_name, ptr_size) =3D=3D 0 >+ && read_one_ptr (lm_addr + lmo->l_addr_offset, >+ &l_addr, ptr_size) =3D=3D 0 >+ && read_one_ptr (lm_addr + lmo->l_ld_offset, >+ &l_ld, ptr_size) =3D=3D 0 >+ && read_one_ptr (lm_addr + lmo->l_prev_offset, >+ &l_prev, ptr_size) =3D=3D 0 >+ && read_one_ptr (lm_addr + lmo->l_next_offset, >+ &l_next, ptr_size) =3D=3D 0) >+ { >+ unsigned char libname[PATH_MAX]; >+ >+ if (lm_prev !=3D l_prev) >+ { >+ warning ("Corrupted shared library list: 0x%lx !=3D 0x%lx", >+ (long) lm_prev, (long) l_prev); >+ break; >+ } >+ >+ /* Ignore the first entry even if it has valid name as the first en= try >+ corresponds to the main executable. The first entry should not be >+ skipped if the dynamic loader was loaded late by a static executable >+ (see solib-svr4.c parameter ignore_first). But in such case the main >+ executable does not have PT_DYNAMIC present and this function already >+ exited above due to failed get_r_debug. */ >+ if (ignore_first && lm_prev =3D=3D 0) >+ string_appendf (document, " main-lm=3D\"0x%lx\"", (unsigned long) >lm_addr); >+ else >+ { >+ /* Not checking for error because reading may stop before >+ we've got PATH_MAX worth of characters. */ >+ libname[0] =3D '\0'; >+ linux_read_memory (l_name, libname, sizeof (libname) - 1); >+ libname[sizeof (libname) - 1] =3D '\0'; >+ if (libname[0] !=3D '\0') >+ { >+ if (!header_done) >+ { >+ /* Terminate `+ document +=3D '>'; >+ header_done =3D 1; >+ } >+ >+ string_appendf (document, "+ xml_escape_text_append (&document, (char *) libname); >+ string_appendf (document, "\" lm=3D\"0x%lx\" " >+ "l_addr=3D\"0x%lx\" l_ld=3D\"0x%lx\"/>", >+ (unsigned long) lm_addr, (unsigned long) l_addr, >+ (unsigned long) l_ld); >+ } >+ } >+ >+ lm_prev =3D lm_addr; >+ lm_addr =3D l_next; >+ } >+} >+ > /* Construct qXfer:libraries-svr4:read reply. */ > > int >@@ -6754,33 +6849,8 @@ linux_process_target::qxfer_libraries_svr4 (const c= har >*annex, > struct process_info_private *const priv =3D current_process ()->priv; > char filename[PATH_MAX]; > int pid, is_elf64; >- >- static const struct link_map_offsets lmo_32bit_offsets =3D >- { >- 0, /* r_version offset. */ >- 4, /* r_debug.r_map offset. */ >- 0, /* l_addr offset in link_map. */ >- 4, /* l_name offset in link_map. */ >- 8, /* l_ld offset in link_map. */ >- 12, /* l_next offset in link_map. */ >- 16 /* l_prev offset in link_map. */ >- }; >- >- static const struct link_map_offsets lmo_64bit_offsets =3D >- { >- 0, /* r_version offset. */ >- 8, /* r_debug.r_map offset. */ >- 0, /* l_addr offset in link_map. */ >- 8, /* l_name offset in link_map. */ >- 16, /* l_ld offset in link_map. */ >- 24, /* l_next offset in link_map. */ >- 32 /* l_prev offset in link_map. */ >- }; >- const struct link_map_offsets *lmo; > unsigned int machine; >- int ptr_size; > CORE_ADDR lm_addr =3D 0, lm_prev =3D 0; >- CORE_ADDR l_name, l_addr, l_ld, l_next, l_prev; > int header_done =3D 0; > > if (writebuf !=3D NULL) >@@ -6791,8 +6861,18 @@ linux_process_target::qxfer_libraries_svr4 (const c= har >*annex, > pid =3D lwpid_of (current_thread); > xsnprintf (filename, sizeof filename, "/proc/%d/exe", pid); > is_elf64 =3D elf_64_file_p (filename, &machine); >- lmo =3D is_elf64 ? &lmo_64bit_offsets : &lmo_32bit_offsets; >- ptr_size =3D is_elf64 ? 8 : 4; >+ const struct link_map_offsets *lmo; >+ int ptr_size; >+ if (is_elf64) >+ { >+ lmo =3D &lmo_64bit_offsets; >+ ptr_size =3D 8; >+ } >+ else >+ { >+ lmo =3D &lmo_32bit_offsets; >+ ptr_size =3D 4; >+ } > > while (annex[0] !=3D '\0') > { >@@ -6821,95 +6901,69 @@ linux_process_target::qxfer_libraries_svr4 (const = char >*annex, > annex =3D decode_address_to_semicolon (addrp, sep + 1); > } > >- if (lm_addr =3D=3D 0) >- { >- int r_version =3D 0; >+ std::string document =3D " >- if (priv->r_debug =3D=3D 0) >- priv->r_debug =3D get_r_debug (pid, is_elf64); >+ /* When the starting LM_ADDR is passed in the annex, only traverse that >+ namespace. >+ >+ Otherwise, start with R_DEBUG and traverse all namespaces we find. = */ >+ if (lm_addr !=3D 0) >+ read_link_map (document, lm_addr, lm_prev, ptr_size, lmo, false, >+ header_done); >+ else >+ { >+ CORE_ADDR lm =3D priv->r_debug; >+ if (lm =3D=3D 0) >+ lm =3D priv->r_debug =3D get_r_debug (pid, is_elf64); > > /* We failed to find DT_DEBUG. Such situation will not change > for this inferior - do not retry it. Report it to GDB as > E01, see for the reasons at the GDB solib-svr4.c side. */ >- if (priv->r_debug =3D=3D (CORE_ADDR) -1) >+ if (lm =3D=3D (CORE_ADDR) -1) > return -1; > >- if (priv->r_debug !=3D 0) >+ bool ignore_first =3D true; >+ while (lm !=3D 0) > { >- if (linux_read_memory (priv->r_debug + lmo->r_version_offset, >+ int r_version =3D 0; >+ if (linux_read_memory (lm + lmo->r_version_offset, > (unsigned char *) &r_version, >- sizeof (r_version)) !=3D 0 >- || r_version < 1) >+ sizeof (r_version)) !=3D 0) >+ { >+ warning ("unable to read r_version from 0x%lx", >+ (long) lm + lmo->r_version_offset); >+ break; >+ } >+ >+ if (r_version < 1) > { > warning ("unexpected r_debug version %d", r_version); >+ break; > } >- else if (read_one_ptr (priv->r_debug + lmo->r_map_offset, >- &lm_addr, ptr_size) !=3D 0) >+ >+ if (read_one_ptr (lm + lmo->r_map_offset, &lm_addr, ptr_size) !=3D 0) > { > warning ("unable to read r_map from 0x%lx", >- (long) priv->r_debug + lmo->r_map_offset); >+ (long) lm + lmo->r_map_offset); >+ break; > } >- } >- } > >- std::string document =3D "+ read_link_map (document, lm_addr, lm_prev, ptr_size, lmo, >+ ignore_first, header_done); > >- while (lm_addr >- && read_one_ptr (lm_addr + lmo->l_name_offset, >- &l_name, ptr_size) =3D=3D 0 >- && read_one_ptr (lm_addr + lmo->l_addr_offset, >- &l_addr, ptr_size) =3D=3D 0 >- && read_one_ptr (lm_addr + lmo->l_ld_offset, >- &l_ld, ptr_size) =3D=3D 0 >- && read_one_ptr (lm_addr + lmo->l_prev_offset, >- &l_prev, ptr_size) =3D=3D 0 >- && read_one_ptr (lm_addr + lmo->l_next_offset, >- &l_next, ptr_size) =3D=3D 0) >- { >- unsigned char libname[PATH_MAX]; >+ if (r_version < 2) >+ break; > >- if (lm_prev !=3D l_prev) >- { >- warning ("Corrupted shared library list: 0x%lx !=3D 0x%lx", >- (long) lm_prev, (long) l_prev); >- break; >- } >+ /* Only applies to the default namespace. */ >+ ignore_first =3D false; > >- /* Ignore the first entry even if it has valid name as the first en= try >- corresponds to the main executable. The first entry should not be >- skipped if the dynamic loader was loaded late by a static executable >- (see solib-svr4.c parameter ignore_first). But in such case the main >- executable does not have PT_DYNAMIC present and this function already >- exited above due to failed get_r_debug. */ >- if (lm_prev =3D=3D 0) >- string_appendf (document, " main-lm=3D\"0x%lx\"", (unsigned long) >lm_addr); >- else >- { >- /* Not checking for error because reading may stop before >- we've got PATH_MAX worth of characters. */ >- libname[0] =3D '\0'; >- linux_read_memory (l_name, libname, sizeof (libname) - 1); >- libname[sizeof (libname) - 1] =3D '\0'; >- if (libname[0] !=3D '\0') >+ if (read_one_ptr (lm + lmo->r_next_offset, &lm, ptr_size) !=3D 0) > { >- if (!header_done) >- { >- /* Terminate `- document +=3D '>'; >- header_done =3D 1; >- } >- >- string_appendf (document, "- xml_escape_text_append (&document, (char *) libname); >- string_appendf (document, "\" lm=3D\"0x%lx\" " >- "l_addr=3D\"0x%lx\" l_ld=3D\"0x%lx\"/>", >- (unsigned long) lm_addr, (unsigned long) l_addr, >- (unsigned long) l_ld); >+ warning ("unable to read r_next from 0x%lx", >+ (long) lm + lmo->r_next_offset); >+ break; > } > } >- >- lm_prev =3D lm_addr; >- lm_addr =3D l_next; > } > > if (!header_done) >-- >2.31.1 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