From patchwork Wed Nov 3 16:28:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 47018 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2EEB43858420 for ; Wed, 3 Nov 2021 16:43:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2EEB43858420 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1635957813; bh=KOIPiB0u0B9vBOh0n3qIdJXW3jsfKrvRvZazyMCQHS8=; h=To:Subject:In-Reply-To:References:Date:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=XYqg7XR6Um64it5V/woO598x9Ne2TvbF+Q3iz5iOzW/xoSMuSty1wT84Af9wZXqXY KJ2Nf4LviBsxhJRjOhiheWKJePSpa1SnKXCS45eNzsoR9TFvw86shfJv17BOtggtAI BC9+3JpHIfxrw3go49kuM1XqabAHhnxph/q111R8= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.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 7D5393858023 for ; Wed, 3 Nov 2021 16:29:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7D5393858023 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-177-suS8xzUhOzipRLqN0QiVhQ-1; Wed, 03 Nov 2021 12:29:00 -0400 X-MC-Unique: suS8xzUhOzipRLqN0QiVhQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 14DFB5074C; Wed, 3 Nov 2021 16:28:59 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.192.3]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C9D61607A1; Wed, 3 Nov 2021 16:28:57 +0000 (UTC) To: gcc-patches@gcc.gnu.org Subject: [PATCH 4/4] libgcc: Use _dl_find_eh_frame in _Unwind_Find_FDE In-Reply-To: References: X-From-Line: adeb300eebaa792d64fca85f1e72fed03c1b32d1 Mon Sep 17 00:00:00 2001 Message-Id: Date: Wed, 03 Nov 2021 17:28:55 +0100 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.7 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_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=unavailable autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Florian Weimer via Libc-alpha From: Florian Weimer Reply-To: Florian Weimer Cc: Jakub Jelinek , libc-alpha@sourceware.org, Jason Merrill Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" libgcc/ChangeLog * unwind-dw2-fde-dip.c (USE_DL_FIND_EH_FRAME) (DL_FIND_EH_FRAME_CONDITION): New macros. [__GLIBC__ && !DL_FIND_EH_FRAME_DBASE] (_dl_find_eh_frame): Declare weak function. (_Unwind_Find_FDE): Call _dl_find_eh_frame if available. --- libgcc/unwind-dw2-fde-dip.c | 50 +++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/libgcc/unwind-dw2-fde-dip.c b/libgcc/unwind-dw2-fde-dip.c index 272c0ec46c0..b5b4a23dc56 100644 --- a/libgcc/unwind-dw2-fde-dip.c +++ b/libgcc/unwind-dw2-fde-dip.c @@ -129,6 +129,30 @@ unw_eh_callback_data_dbase (const struct unw_eh_callback_data *data #endif } +#ifdef DL_FIND_EH_FRAME_DBASE +#if DL_FIND_EH_FRAME_DBASE != NEED_DBASE_MEMBER +#error "DL_FIND_EH_FRAME_DBASE != NEED_DBASE_MEMBER" +#endif +#define USE_DL_FIND_EH_FRAME 1 +#define DL_FIND_EH_FRAME_CONDITION 1 +#endif + +/* Fallback declaration for old glibc headers. DL_FIND_EH_FRAME_DBASE is used + as a proxy to determine if declares _dl_find_eh_frame. */ +#if defined __GLIBC__ && !defined DL_FIND_EH_FRAME_DBASE +#if NEED_DBASE_MEMBER +void *_dl_find_eh_frame (void *__pc, void **__dbase) __attribute__ ((weak)); +#else +void *_dl_find_eh_frame (void *__pc) __attribute__ ((weak)); +#endif +#define USE_DL_FIND_EH_FRAME 1 +#define DL_FIND_EH_FRAME_CONDITION (_dl_find_eh_frame != NULL) +#endif + +#ifndef USE_DL_FIND_EH_FRAME +#define USE_DL_FIND_EH_FRAME 0 +#endif + struct unw_eh_frame_hdr { unsigned char version; @@ -501,6 +525,32 @@ _Unwind_Find_FDE (void *pc, struct dwarf_eh_bases *bases) if (ret != NULL) return ret; +#if USE_DL_FIND_EH_FRAME + if (DL_FIND_EH_FRAME_CONDITION) + { + void *dbase; + void *eh_frame; +#if NEED_DBASE_MEMBER + eh_frame = _dl_find_eh_frame (pc, &dbase); +#else + dbase = NULL; + eh_frame = _dl_find_eh_frame (pc); +#endif + if (eh_frame == NULL) + return NULL; + + struct find_fde_tail_result result + = find_fde_tail ((_Unwind_Ptr) pc, eh_frame, (_Unwind_Ptr) dbase); + if (result.entry != NULL) + { + bases->tbase = NULL; + bases->dbase = (void *) dbase; + bases->func = result.func; + } + return result.entry; + } +#endif + data.pc = (_Unwind_Ptr) pc; #if NEED_DBASE_MEMBER data.dbase = NULL;