From patchwork Fri Jan 12 04:56:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sandra Loosemore X-Patchwork-Id: 1885869 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TB8R45G7yz1yPf for ; Fri, 12 Jan 2024 15:57:18 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C7BE13858418 for ; Fri, 12 Jan 2024 04:57:15 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa1.mentor.iphmx.com (esa1.mentor.iphmx.com [68.232.129.153]) by sourceware.org (Postfix) with ESMTPS id 8D4FD3858D32 for ; Fri, 12 Jan 2024 04:56:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8D4FD3858D32 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 8D4FD3858D32 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=68.232.129.153 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705035415; cv=none; b=qBuKptuJ3TYmHUfn/NG1Lq/nntHhNLnzH9EuSVrb7Tk34PNXmc8aET7gSR+F38NyhfBLmq3XiQ25TsYSqTfrD5DjjMxyqjQwN6MJYWJKQrX2USwPxMlBXVGpxlxC1rNNkwmsCMI1iUonNrSne10FWsfZe/G96F0r6Ct77DHofCs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705035415; c=relaxed/simple; bh=nyz7GYKiiR7VVf6tHiOBejN/+pFTpODXL80H6hSuzOc=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=vULJqFf9PkjizWVzJtq0mLpq2wTqxLtIJip1PFRDIYK2AqWQSdLf6NEeHuILTz2Ba2ybIK9wGwblkoHNNqh0TE/zzoo/3ASH2NX6m5vmW0DNWE5ftNAWIVH2CFwal+Vl0QmY+MiAcct+KzUVPJyz78am8/TjoWZlBUhLC+CEsTc= ARC-Authentication-Results: i=1; server2.sourceware.org X-CSE-ConnectionGUID: 4gfAUCVdQAysfP5F/iFi7w== X-CSE-MsgGUID: GKzjRZgWTaO00//O97voPA== X-IronPort-AV: E=Sophos;i="6.04,188,1695715200"; d="scan'208";a="31375387" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa1.mentor.iphmx.com with ESMTP; 11 Jan 2024 20:56:52 -0800 IronPort-SDR: Kpzm/K3suoTt7j/PE67cxKlEbaEgkxnngOKISloslfpeTwkRIrmRtK36t7hVE2MWtHBkfPBBea LNzawkQpUvKrSWyH/jbloJ3DT+GD1Lp+U8uaX/mtY08fNFOTW9Ym/7FBEn2Rtoi+EeI9RrQ/8A +JVhBZXOWvfgn0yshbmvEvh6xkieY5My3SuIwvPy7LLS+RbiVHuq5bUyaEY+m+QxFiyN5xH7Oz gA7JQqi/oBch44EM/SBfSIUDVJaHcAQ66XUZeSm31wFfOH0pgjJaJMhlnI01jHTwuolomaVOMS C9E= From: Sandra Loosemore To: Subject: [Committed] libgcc, nios2: Fix exception handling on nios2 with -fpic Date: Thu, 11 Jan 2024 21:56:32 -0700 Message-ID: <20240112045633.2643599-1-sandra@codesourcery.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-ClientProxiedBy: svr-orw-mbx-14.mgc.mentorg.com (147.34.90.214) To svr-orw-mbx-13.mgc.mentorg.com (147.34.90.213) X-Spam-Status: No, score=-10.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, 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: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Exception handling on nios2-linux-gnu with -fpic has been broken since revision 790854ea7670f11c14d431c102a49181d2915965, "Use _dl_find_object in _Unwind_Find_FDE". For whatever reason, this doesn't work on nios2. Nios2 uses the GOT address as the base for DW_EH_PE_datarel relocations in PIC; see my previous fix to make this work, revision 2d33dcfe9f0494c9b56a8d704c3d27c5a4329ebc, "Support for GOT-relative DW_EH_PE_datarel encoding". So this may be a horrible bug in the ABI or in my interpretation of it or just glibc's implementation of _dl_find_object for this target, but there's existing code out there that does things this way; and realistically, nobody is going to re-engineer this now that the vendor has EOL'ed the nios2 architecture. So, just skip over the code trying to use _dl_find_object on this target and fall back to the way that works. I plan to backport this patch to the GCC 12 and GCC 13 branches as well. libgcc/ChangeLog * unwind-dw2-fde-dip.c (_Unwind_Find_FDE): Do not try to use _dl_find_object on nios2; it doesn't work. --- libgcc/unwind-dw2-fde-dip.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libgcc/unwind-dw2-fde-dip.c b/libgcc/unwind-dw2-fde-dip.c index 2f2ca35d549..57d0c8812b1 100644 --- a/libgcc/unwind-dw2-fde-dip.c +++ b/libgcc/unwind-dw2-fde-dip.c @@ -543,8 +543,9 @@ _Unwind_Find_FDE (void *pc, struct dwarf_eh_bases *bases) return ret; /* Use DLFO_STRUCT_HAS_EH_DBASE as a proxy for the existence of a glibc-style - _dl_find_object function. */ -#ifdef DLFO_STRUCT_HAS_EH_DBASE + _dl_find_object function. However, do not use _dl_find_object on nios2, + which uses the GOT address as the base for DW_EH_PE_datarel instead. */ +#if defined(DLFO_STRUCT_HAS_EH_DBASE) && !defined(__nios2__) { struct dl_find_object dlfo; if (_dl_find_object (pc, &dlfo) == 0 && dlfo.dlfo_eh_frame != NULL)