From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx07-00178001.pphosted.com (mx07-00178001.pphosted.com [185.132.182.106]) by sourceware.org (Postfix) with ESMTPS id 1E03938582A4 for ; Wed, 28 Sep 2022 13:39:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1E03938582A4 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=foss.st.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=foss.st.com Received: from pps.filterd (m0288072.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 28SBYm1r020616; Wed, 28 Sep 2022 15:39:24 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=message-id : date : mime-version : subject : to : references : from : in-reply-to : content-type : content-transfer-encoding; s=selector1; bh=ht0r953R4vyb7cWHp1rCoiCoSYU1B8O1mb+1nelkRbU=; b=Y8f6QQFTVfJTfCGIcxipatCRGLvc/jIj2Zi9o7llW0N0ueJcrjKMrhk+h49ydOIBPMUN XxHIcprU8GfqemYpiTCPIW+cJP5CKvsRHdfWjKPouk4gNsQRY8ZluMZcfdrSGxH+ljhe /9W77gGjztbNMxeqoPkpUn7fH2QZl+nH2+1bjnvTThYpJj7uIfzxmsXkyrjQTSRqXGFW 9dQb2tFD4eejy896fN+LfLJOupz2ikceX6RUKhZCst7gG2ktu14YtMFb/ZvyEfdVjiRr CBr5ZGxbGSrInVa+t4R6HD/kO2/BT6DJnPKfolQAGzhjMmGGXX0GlgYxrxZJNyB3GWzV CQ== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 3jsqamh7dx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 28 Sep 2022 15:39:24 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id C452B10002A; Wed, 28 Sep 2022 15:39:22 +0200 (CEST) Received: from Webmail-eu.st.com (shfdag1node3.st.com [10.75.129.71]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id B7D8422F7B7; Wed, 28 Sep 2022 15:39:22 +0200 (CEST) Received: from [10.252.30.137] (10.75.127.48) by SHFDAG1NODE3.st.com (10.75.129.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2375.31; Wed, 28 Sep 2022 15:39:20 +0200 Message-ID: <5c21c50f-c75c-6cc7-4994-85a1f9892020@foss.st.com> Date: Wed, 28 Sep 2022 15:39:19 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.3.0 Subject: Re: PING^1 [PATCH] testsuite: 'b' instruction can't do long enough jumps Content-Language: en-US To: Christophe Lyon , References: <20220919163040.4104646-1-torbjorn.svensson@foss.st.com> <9ffd26d4-a14f-2ffa-e6e5-750331fd3cdc@foss.st.com> From: Torbjorn SVENSSON In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.75.127.48] X-ClientProxiedBy: SFHDAG2NODE3.st.com (10.75.127.6) To SHFDAG1NODE3.st.com (10.75.129.71) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.528,FMLib:17.11.122.1 definitions=2022-09-28_06,2022-09-28_01,2022-06-22_01 X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00,BODY_8BITS,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,GIT_PATCH_0,KAM_SHORT,NICE_REPLY_A,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi Christophe! On 2022-09-28 13:55, Christophe Lyon wrote: > Hi! > > > On 9/28/22 11:17, Torbjorn SVENSSON via Gcc-patches wrote: >> Hi, >> >> Ping: >> https://gcc.gnu.org/pipermail/gcc-patches/2022-September/601829.html >> >> Kind regards, >> Torbjörn >> >> On 2022-09-19 18:30, Torbjörn SVENSSON wrote: >>> After moving the testglue in commit 9d503515cee, the jump to exit and >>> abort is too far for the 'b' instruction on Cortex-M0. As most of the > I am not sure I understand why that commit changed the distance between > 'exit' and the branch instruction? The change was that the gcc_tg.o (the DejaGNU testglue.c object file) is now put last on the command line. In the previous versions of GCC, it was put before the ldflags flag etc, so now the code is placed in a way that the distance might be too big. This could also be related to that we in ST are using QEMU in system mode and not user mode and as a result, our test environment is slightly larger and might perhaps be placed in between the code for the test case and the testglue. >>> C code would generate a 'bl' instruction instead of a 'b' >>> instruction, lets do the same for the inline assembler. >>> >>> The error seen without this patch: >>> >>> /tmp/cccCRiCl.o: in function `main': >>> stack-protector-1.c:(.text+0x4e): relocation truncated to fit: >>> R_ARM_THM_JUMP11 against symbol `__wrap_exit' defined in .text >>> section in gcc_tg.o >>> stack-protector-1.c:(.text+0x50): relocation truncated to fit: >>> R_ARM_THM_JUMP11 against symbol `__wrap_abort' defined in .text >>> section in gcc_tg.o >>> collect2: error: ld returned 1 exit status >>> > Anyway the change seems sensible to me, I suppose it's not worth adding > support in the linker to insert long branch stubs for these relocations. If a simple 'bl' instead of 'b' is enough, I think that this trivial change is the right one as the test case is supposed to test the stack protection, not branching, right? Kind regards, Torbjörn > > Christophe > >>> gcc/testsuite/ChangeLog: >>> >>>          * gcc/testsuite/gcc.target/arm/stack-protector-1.c: Use 'bl' >>>     instead of 'b' instruction. >>>     * gcc/testsuite/gcc.target/arm/stack-protector-3.c: Likewise. >>> >>> Co-Authored-By: Yvan ROUX  >>> Signed-off-by: Torbjörn SVENSSON  >>> --- >>>   gcc/testsuite/gcc.target/arm/stack-protector-1.c | 4 ++-- >>>   gcc/testsuite/gcc.target/arm/stack-protector-3.c | 2 +- >>>   2 files changed, 3 insertions(+), 3 deletions(-) >>> >>> diff --git a/gcc/testsuite/gcc.target/arm/stack-protector-1.c >>> b/gcc/testsuite/gcc.target/arm/stack-protector-1.c >>> index 8d28b0a847c..3f0ffc9c3f3 100644 >>> --- a/gcc/testsuite/gcc.target/arm/stack-protector-1.c >>> +++ b/gcc/testsuite/gcc.target/arm/stack-protector-1.c >>> @@ -56,8 +56,8 @@ asm ( >>>   "    ldr    r1, [sp, #4]\n" >>>       CHECK (r1) >>>   "    mov    r0, #0\n" >>> -"    b    exit\n" >>> +"    bl    exit\n" >>>   "1:\n" >>> -"    b    abort\n" >>> +"    bl    abort\n" >>>   "    .size    main, .-main" >>>   ); >>> diff --git a/gcc/testsuite/gcc.target/arm/stack-protector-3.c >>> b/gcc/testsuite/gcc.target/arm/stack-protector-3.c >>> index b8f77fa2309..2f710529b8f 100644 >>> --- a/gcc/testsuite/gcc.target/arm/stack-protector-3.c >>> +++ b/gcc/testsuite/gcc.target/arm/stack-protector-3.c >>> @@ -26,7 +26,7 @@ asm ( >>>   "    .type    __stack_chk_fail, %function\n" >>>   "__stack_chk_fail:\n" >>>   "    movs    r0, #0\n" >>> -"    b    exit\n" >>> +"    bl    exit\n" >>>   "    .size    __stack_chk_fail, .-__stack_chk_fail" >>>   );