From patchwork Tue Jun 6 09:51:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 103695 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp3271600vqr; Tue, 6 Jun 2023 02:53:35 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5i1JiRir26YFIafArEcsGaa5DtzPlFngxeDKUnrFn989u+nnKquLPTIx65jYGXJDp5gA9g X-Received: by 2002:a17:906:9754:b0:977:d228:5b88 with SMTP id o20-20020a170906975400b00977d2285b88mr1817091ejy.75.1686045215622; Tue, 06 Jun 2023 02:53:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686045215; cv=none; d=google.com; s=arc-20160816; b=MXFhV3HDiAADC2MOnD0rb9FSzPNMePU75r1g4k6/SBXqU3GI8493XvngOTXNNr3u7j BeADxPPbo0OgZnXMMFx9X0ruS0IzjGKlIdMZ8zDMUs71sMcPFUt8cM2SKDvW8GG9XqNC f+t1rfQm5W0UdaFrFzuNf6Uk4CbJKwI72lDMIAXLRf2i1CS0BMy3/3KJSGK18mA8GqYp RRWVIp3N8bXGXSMHUWk2+I1BhYYOnlw8kLL7GSmhLtoYVKbEBQsh47/dPYalXlNYNWMo IvTQ+DY8TfjcB+0l8xhmDL1cDOe1V+UeWcGgRB3Z+9peUvkopjx12jvq0vmsZX1BLZnr RC+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:mime-version :user-agent:message-id:date:subject:to:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=WFbZBDed2i7adD69kxSgG73WfAD0tpYRA7aiZI3p1uk=; b=tGRP7amZYThoM5lAJJWoID8cra6fyg9pkVMI7kC5O5I/1+G/xX4ocLFtylHxHXp8zD Tw4omr5eL/JpI2K4lM40n1djeq0Nt96WcYzF55EUncH5CUiTBwAbzJE3PStIPytxZtmb LLirWCvnXzofPpiCmYMqiMmZUp3a7LIq0FAZF7C+Dy+hVSs6eB87R2js7zhojJLGGsn3 osN+/UGp2Rt3MVMtuVL/mko8kkMIWoQPYqKZNBpTXCdYKSxhEUJ9k08FrR+Z+UVVfn4Y gJU7uWRx+5+/YmwHkntkdoabGMZnkJLRoXCuEzijya7pKNZ2djY1q85hr1vZS/Vn+WeS U4Kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=CSPpWSag; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id ja25-20020a170907989900b0096a1b3e66desi5911134ejc.1020.2023.06.06.02.53.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jun 2023 02:53:35 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=CSPpWSag; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 73FD63857715 for ; Tue, 6 Jun 2023 09:52:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 73FD63857715 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686045176; bh=WFbZBDed2i7adD69kxSgG73WfAD0tpYRA7aiZI3p1uk=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=CSPpWSag/LiLLZSrMW2pCz/u5XKr8Y5YL4i0rxSgvQtfLkEREBAkfHAvSAADkaeJi uBC6Pdd+jPm4y45PEKlBtJERGo18/xNDR/KH4OfpjFyqXCRGMB0BwXmhNP27SVWD+n YwdCLsTYLPoNb/0qdSMJ7vIOhID51jdPqyc5hy+c= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id D99C7385802F for ; Tue, 6 Jun 2023 09:51:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D99C7385802F Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-653-7vMVKUL0OYuJ1U_sGBUaKA-1; Tue, 06 Jun 2023 05:51:29 -0400 X-MC-Unique: 7vMVKUL0OYuJ1U_sGBUaKA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 778F72999B31 for ; Tue, 6 Jun 2023 09:51:28 +0000 (UTC) Received: from oldenburg3.str.redhat.com (unknown [10.39.193.74]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 04C1E140E954 for ; Tue, 6 Jun 2023 09:51:27 +0000 (UTC) To: gcc-patches@gcc.gnu.org Subject: [PATCH] libgcc: Fix eh_frame fast path in find_fde_tail Date: Tue, 06 Jun 2023 11:51:26 +0200 Message-ID: <871qioapgh.fsf@oldenburg3.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, 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: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Florian Weimer via Gcc-patches From: Florian Weimer Reply-To: Florian Weimer Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767946548071033382?= X-GMAIL-MSGID: =?utf-8?q?1767946548071033382?= The eh_frame value is only used by linear_search_fdes, not the binary search directly in find_fde_tail, so the bug is not immediately apparent with most programs. Fixes commit e724b0480bfa5ec04f39be8c7290330b495c59de ("libgcc: Special-case BFD ld unwind table encodings in find_fde_tail"). [I'd appreciate suggestions how I could add a test for this. BFD ld does not seem to allow ommitting the binary search table.] libgcc/ PR libgcc/109712 * unwind-dw2-fde-dip.c (find_fde_tail): Correct fast path for parsing eh_frame. --- libgcc/unwind-dw2-fde-dip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) base-commit: b327cbe8f4eefc91ee2bea49a1da7128adf30281 diff --git a/libgcc/unwind-dw2-fde-dip.c b/libgcc/unwind-dw2-fde-dip.c index 6223f5f18a2..4e0b880513f 100644 --- a/libgcc/unwind-dw2-fde-dip.c +++ b/libgcc/unwind-dw2-fde-dip.c @@ -403,8 +403,8 @@ find_fde_tail (_Unwind_Ptr pc, BFD ld generates. */ signed value __attribute__ ((mode (SI))); memcpy (&value, p, sizeof (value)); + eh_frame = p + value; p += sizeof (value); - dbase = value; /* No adjustment because pcrel has base 0. */ } else p = read_encoded_value_with_base (hdr->eh_frame_ptr_enc,