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: 1791001 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=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=rYWtji62; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Qb5PH4p3Fz20QH for ; Tue, 6 Jun 2023 19:52:35 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 263DB3856962 for ; Tue, 6 Jun 2023 09:52:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 263DB3856962 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686045153; bh=WFbZBDed2i7adD69kxSgG73WfAD0tpYRA7aiZI3p1uk=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=rYWtji62iwd8JEul11v2t7/bPOKl7+NMXkGPk/adhAI8JiQBzstm9Ixsf48X//dn8 qM5d8m1/UVQKvEa6IZnRqne124t/jdS8oZjsLPmuCxcBpzmwxpV8g8K54vm5/iG9Qz C023Wh6VOaud1ctF/cD7V4TzLegcV/Yd7rJKc5cM= 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+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" 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,