From patchwork Fri May 25 08:03:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Christophe Lyon X-Patchwork-Id: 136811 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp3299094lji; Fri, 25 May 2018 01:43:37 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrg9Mt3jto79zaK6SFgMoGyC8ZKxXycjE0UTpVSW/ELYoM+YX5sTXE7Hnl+T+dI0K2vFHxP X-Received: by 2002:a17:902:8a82:: with SMTP id p2-v6mr1676267plo.244.1527237817822; Fri, 25 May 2018 01:43:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527237817; cv=none; d=google.com; s=arc-20160816; b=Uy1vTqh55SIHxYbSICmEPVh4wiuGEQGmMgKhbPF6fL0XIEeKEOrhXv/AfLssVSBhEU 10SsKrZVXScUqyqsR04UhZ6quZIbLSNF4aIajt9BjmAHQnbn4HaGWFglgsnIWuWfPkZC AhFtN7rf0SK3YKJsW+vEHmV/4RsUD6CONf0JeNGKGkzHLOz602sUqRxqWeU9h2ZLQZCz 6bft7ssL5pq7hHew0FVj2kUWjp3x0GAHm7d+U/0Ux6uVn0wH5esYLKArFXhGzYnj61/H 4vhdd91ja1t17n1/lu2PlGfIQhCGwSsGsrmJG8GVUEHSUGw6Gdc8R54VjwGx6AzAlL/l Jmug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:delivered-to:sender:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :mailing-list:dkim-signature:domainkey-signature :arc-authentication-results; bh=//HYn1APB4f/roQZAkaRhZOGeGI92X2Nn0I9HE3JlY4=; b=sWcsXMH04KgaMEZEp1fgEidOW2bwqbsbbcpz3eqHTku6q+xwzw//Y9pfr+qQFpKY9M T4ntOh7qQD9MXKglRUMHD8BGcZldgqmKK1gM6sXi93bIykb7gziXVZR5uq7FrcEKaM0D zrJq8Nw/c9s50Ha1Au607OY2SC4p+qPULlcDKlP31t6UDXMMrMGwUOz/M2gg/PM51/zU ykfUmppPkMfX/uiu28Bu7Og1NBXohZ6bknM1GjIiQWIOBbbzrd/UzTdzoSX6TZBpCN3e pP/GBIaMTqJyRVXpLIyPjky6NB1GVYbY/Yqv1puZl/K/S+pcBUvbYC0D/5OfJTWYXmn8 DI3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=d2vj2mEA; spf=pass (google.com: domain of gcc-patches-return-478478-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-478478-patch=linaro.org@gcc.gnu.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id m11-v6si22820592pls.497.2018.05.25.01.43.37 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 25 May 2018 01:43:37 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-478478-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=d2vj2mEA; spf=pass (google.com: domain of gcc-patches-return-478478-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-478478-patch=linaro.org@gcc.gnu.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:in-reply-to:references:mime-version :content-type:content-transfer-encoding; q=dns; s=default; b=qG4 T1Lvaa4kNNRN12ei5xluGX4ObIaimVLar3K38e9puMDEgg626E4dIqC7+iX0HK8x EcUCYdaxUpTDCf9+0zrQ9UdN7em8HUioAkupAOKO0+24iuQv02CyPZUszYuR0fre wLsVmg5UxaXg/pn2pmI7atz+vY/9Jqu/PW2F2qWU= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:in-reply-to:references:mime-version :content-type:content-transfer-encoding; s=default; bh=lNhOJW2jY wdnUAOhtSZsawR41Yw=; b=d2vj2mEAwcLTkg78kyfCPgDgN7h2EXZaMhNxeQUg5 3whd1k5lXeC41Ybtrmanes1Swvv7sjd1llM8qgZUpJEUibT+QxWfnxc4wnY7DfX7 bmk01QAQsvupUkkIKmOstKqgHAuzLfP6oExiAqs4gJshhveJrK7L4uANwkw+uLy2 qQ= Received: (qmail 122632 invoked by alias); 25 May 2018 08:22:46 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 54621 invoked by uid 89); 25 May 2018 08:08:41 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-27.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx07-00178001.pphosted.com Received: from mx08-00178001.pphosted.com (HELO mx07-00178001.pphosted.com) (91.207.212.93) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 25 May 2018 08:08:38 +0000 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx08-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id w4P7xHBs010097; Fri, 25 May 2018 10:08:36 +0200 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2j59j8k6j9-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Fri, 25 May 2018 10:08:36 +0200 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 6F5623D; Fri, 25 May 2018 08:08:33 +0000 (GMT) Received: from Webmail-eu.st.com (sfhdag5node1.st.com [10.75.127.13]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 1BE4B1404; Fri, 25 May 2018 08:08:33 +0000 (GMT) Received: from gnb.st.com (10.75.127.51) by SFHDAG5NODE1.st.com (10.75.127.13) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Fri, 25 May 2018 10:08:32 +0200 From: Christophe Lyon To: , Subject: [ARM/FDPIC 13/21] [ARM] FDPIC: Support unwinding across thumb2 signal trampoline Date: Fri, 25 May 2018 10:03:26 +0200 Message-ID: <20180525080354.13295-14-christophe.lyon@st.com> In-Reply-To: <20180525080354.13295-1-christophe.lyon@st.com> References: <20180525080354.13295-1-christophe.lyon@st.com> MIME-Version: 1.0 X-ClientProxiedBy: SFHDAG1NODE2.st.com (10.75.127.2) To SFHDAG5NODE1.st.com (10.75.127.13) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-05-25_03:, , signatures=0 X-IsSubscribed: yes 2018-XX-XX Christophe Lyon Mickaël Guêné libgcc/ * unwind-arm-common.inc (FDPIC_T2_LDR_R12_WITH_FUNCDESC) (FDPIC_T2_LDR_R9_WITH_GOT, FDPIC_T2_LDR_PC_WITH_RESTORER): New. (__gnu_personality_sigframe_fdpic): Support Thumb address. (get_eit_entry): Support Thumb code. Change-Id: I2bb8994e733e48a89c6f4e0682921186c086f8bc -- 2.6.3 diff --git a/libgcc/unwind-arm-common.inc b/libgcc/unwind-arm-common.inc index 80d1e88..7de4033 100644 --- a/libgcc/unwind-arm-common.inc +++ b/libgcc/unwind-arm-common.inc @@ -38,6 +38,9 @@ #define FDPIC_LDR_R12_WITH_FUNCDESC 0xe59fc004 #define FDPIC_LDR_R9_WITH_GOT 0xe59c9004 #define FDPIC_LDR_PC_WITH_RESTORER 0xe59cf000 +#define FDPIC_T2_LDR_R12_WITH_FUNCDESC 0xc008f8df +#define FDPIC_T2_LDR_R9_WITH_GOT 0x9004f8dc +#define FDPIC_T2_LDR_PC_WITH_RESTORER 0xf000f8dc #define FDPIC_FUNCDESC_OFFSET 12 /* Signal frame offsets. */ #define ARM_NEW_RT_SIGFRAME_UCONTEXT 0x80 @@ -228,7 +231,7 @@ __gnu_personality_sigframe_fdpic (_Unwind_State state, _Unwind_VRS_Get (context, _UVRSC_CORE, R_SP, _UVRSD_UINT32, &sp); _Unwind_VRS_Get (context, _UVRSC_CORE, R_PC, _UVRSD_UINT32, &pc); - funcdesc = *(unsigned int *)(pc + FDPIC_FUNCDESC_OFFSET); + funcdesc = *(unsigned int *)((pc & ~1) + FDPIC_FUNCDESC_OFFSET); handler = *(unsigned int *)(funcdesc); first_handler_instruction = *(unsigned int *)(handler & ~1); @@ -277,10 +280,13 @@ get_eit_entry (_Unwind_Control_Block *ucbp, _uw return_address) /* If we are unwinding a signal handler then perhaps we have reached a trampoline. Try to detect jump to restorer sequence. */ - _uw *pc = (_uw *)((return_address+2) & ~3); - if (pc[0] == FDPIC_LDR_R12_WITH_FUNCDESC - && pc[1] == FDPIC_LDR_R9_WITH_GOT - && pc[2] == FDPIC_LDR_PC_WITH_RESTORER) + _uw *pc = (_uw *)((return_address+2) & ~1); + if ((pc[0] == FDPIC_LDR_R12_WITH_FUNCDESC + && pc[1] == FDPIC_LDR_R9_WITH_GOT + && pc[2] == FDPIC_LDR_PC_WITH_RESTORER) + || (pc[0] == FDPIC_T2_LDR_R12_WITH_FUNCDESC + && pc[1] == FDPIC_T2_LDR_R9_WITH_GOT + && pc[2] == FDPIC_T2_LDR_PC_WITH_RESTORER)) { struct funcdesc_t *funcdesc = (struct funcdesc_t *) &__gnu_personality_sigframe_fdpic; @@ -309,13 +315,16 @@ get_eit_entry (_Unwind_Control_Block *ucbp, _uw return_address) /* If we are unwinding a signal handler then perhaps we have reached a trampoline. Try to detect jump to restorer sequence. */ - _uw *pc = (_uw *)((return_address+2) & ~3); - if (pc[0] == FDPIC_LDR_R12_WITH_FUNCDESC - && pc[1] == FDPIC_LDR_R9_WITH_GOT - && pc[2] == FDPIC_LDR_PC_WITH_RESTORER) + _uw *pc = (_uw *)((return_address+2) & ~1); + if ((pc[0] == FDPIC_LDR_R12_WITH_FUNCDESC + && pc[1] == FDPIC_LDR_R9_WITH_GOT + && pc[2] == FDPIC_LDR_PC_WITH_RESTORER) + || (pc[0] == FDPIC_T2_LDR_R12_WITH_FUNCDESC + && pc[1] == FDPIC_T2_LDR_R9_WITH_GOT + && pc[2] == FDPIC_T2_LDR_PC_WITH_RESTORER)) { - struct funcdesc_t *funcdesc = (struct funcdesc_t *) - &__gnu_personality_sigframe_fdpic; + struct funcdesc_t *funcdesc + = (struct funcdesc_t *) &__gnu_personality_sigframe_fdpic; UCB_PR_ADDR (ucbp) = funcdesc->ptr; UCB_PR_GOT (ucbp) = funcdesc->got; @@ -335,13 +344,16 @@ get_eit_entry (_Unwind_Control_Block *ucbp, _uw return_address) /* If we are unwinding a signal handler then perhaps we have reached a trampoline. Try to detect jump to restorer sequence. */ - _uw *pc = (_uw *)((return_address+2) & ~3); - if (pc[0] == FDPIC_LDR_R12_WITH_FUNCDESC - && pc[1] == FDPIC_LDR_R9_WITH_GOT - && pc[2] == FDPIC_LDR_PC_WITH_RESTORER) + _uw *pc = (_uw *)((return_address+2) & ~1); + if ((pc[0] == FDPIC_LDR_R12_WITH_FUNCDESC + && pc[1] == FDPIC_LDR_R9_WITH_GOT + && pc[2] == FDPIC_LDR_PC_WITH_RESTORER) + || (pc[0] == FDPIC_T2_LDR_R12_WITH_FUNCDESC + && pc[1] == FDPIC_T2_LDR_R9_WITH_GOT + && pc[2] == FDPIC_T2_LDR_PC_WITH_RESTORER)) { - struct funcdesc_t *funcdesc = (struct funcdesc_t *) - &__gnu_personality_sigframe_fdpic; + struct funcdesc_t *funcdesc + = (struct funcdesc_t *) &__gnu_personality_sigframe_fdpic; UCB_PR_ADDR (ucbp) = funcdesc->ptr; UCB_PR_GOT (ucbp) = funcdesc->got;