From patchwork Wed Jun 1 08:45:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Marie de Rodat X-Patchwork-Id: 1637839 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.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=gcgH2JiM; dkim-atps=neutral Authentication-Results: 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=) 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 RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4LCjth2dPyz9s0w for ; Wed, 1 Jun 2022 19:06:18 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 584C538344C3 for ; Wed, 1 Jun 2022 09:06:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 584C538344C3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1654074376; bh=c+OGNV1MRBvKAO6zij31+iqK8NULoMDLZN/Xgw9EWW4=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=gcgH2JiMYdc8kl+ZiqVACaCtfRsPpuF1Qq+3il8CMzGXyzfaueaRr4p9xZ/ySl7vK qgrbeMnsAZ/joCrttaD2NcCH5/7BmriDVkbMsDdEuDIrfncbMxhWY5VeiIPjZqgQvo yySXXHG26sNEiIHsexWX8tGnahnsQaHfmCR3Sweg= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by sourceware.org (Postfix) with ESMTPS id 944403836649 for ; Wed, 1 Jun 2022 08:45:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 944403836649 Received: by mail-ed1-x52c.google.com with SMTP id c2so1194641edf.5 for ; Wed, 01 Jun 2022 01:45:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=c+OGNV1MRBvKAO6zij31+iqK8NULoMDLZN/Xgw9EWW4=; b=gAX4iXngm5EtwXTfe0CLLgoN0CCzsrkfEhbZwUn61RPjBsB4EAZpsvtc+9S2c/lGp+ RgYeQ5Fn0GDxvAQJyOFpcq3bt31FQvv+7RIGwnz8X+jr5Bz3I/iIJpxxak5UbZLSE0tN 8E6ekhSJ81ZbUv47KvQTwmFy1Sw5XeukcovJ6ef4O+fjy5hr6K10++0438aphTzTkFOm WdF0rKfegBkttbiogF2aWD4qqGL9eyAjooHdhyq0yyHB2quBt8ilztj4/3kAV5M5mTWX b/HnL+UeDMSFtjCc2cleg0P7qveDo34tXBRTTD1ldywsMSockWePaQO4J6zkMuSUh77W 2cwA== X-Gm-Message-State: AOAM533Tohq0dwJ+aTi/ep0n5vAnO2cyaRJiE8vPNfTtJd8P/ub4Q0oc DMpxgkTmJtDkGxs0r3lEDZRsNeHF6MAELw== X-Google-Smtp-Source: ABdhPJwuVel1obTWzJx0Y5965f+X1ZZA/7Lgm1won1IF5j6vlbSekjToc+/hKwLPKHRA6nG+yxuLQA== X-Received: by 2002:a05:6402:3712:b0:42d:d762:32cd with SMTP id ek18-20020a056402371200b0042dd76232cdmr12521447edb.408.1654073116410; Wed, 01 Jun 2022 01:45:16 -0700 (PDT) Received: from adacore.com ([45.147.211.82]) by smtp.gmail.com with ESMTPSA id bv15-20020a170906b1cf00b006f4c4330c49sm448520ejb.57.2022.06.01.01.45.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jun 2022 01:45:15 -0700 (PDT) Date: Wed, 1 Jun 2022 08:45:15 +0000 To: gcc-patches@gcc.gnu.org Subject: [Ada] arm-qnx-7.1: unwind goes wrong after regs restore Message-ID: <20220601084515.GA1247637@adacore.com> MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Pierre-Marie de Rodat via Gcc-patches From: Pierre-Marie de Rodat Reply-To: Pierre-Marie de Rodat Cc: Doug Rupp Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Bump the pc +3 total for Thumb mode, the same calculation that as is done for arm-linux. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * init.c (__gnat_adjust_context_for_raise) [QNX][__thumb2__]: Bump the pc an extra byte. diff --git a/gcc/ada/init.c b/gcc/ada/init.c --- a/gcc/ada/init.c +++ b/gcc/ada/init.c @@ -2579,7 +2579,17 @@ __gnat_adjust_context_for_raise (int signo ATTRIBUTE_UNUSED, uintptr_t *pc_addr; mcontext_t *mcontext = &((ucontext_t *) sc)->uc_mcontext; pc_addr = (uintptr_t *)&mcontext->cpu.gpr [ARM_REG_PC]; + + /* ARM Bump has to be an even number because of odd/even architecture. */ *pc_addr += 2; +#ifdef __thumb2__ + /* For thumb, the return address must have the low order bit set, otherwise + the unwinder will reset to "arm" mode upon return. As long as the + compilation unit containing the landing pad is compiled with the same + mode (arm vs thumb) as the signaling compilation unit, this works. */ + if (mcontext->cpu.spsr & ARM_CPSR_T) + *pc_addr += 1; +#endif } #endif /* ARMEL */