testsuite: 'b' instruction can't do long enough jumps

Message ID 20220919163040.4104646-1-torbjorn.svensson@foss.st.com
State Accepted, archived
Headers
Series testsuite: 'b' instruction can't do long enough jumps |

Checks

Context Check Description
snail/gcc-patches-check success Github commit url

Commit Message

Torbjorn SVENSSON Sept. 19, 2022, 4:30 p.m. UTC
  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
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

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  <yvan.roux@foss.st.com>
Signed-off-by: Torbjörn SVENSSON  <torbjorn.svensson@foss.st.com>
---
 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(-)
  

Comments

Torbjorn SVENSSON Sept. 28, 2022, 9:17 a.m. UTC | #1
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
> 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
> 
> 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  <yvan.roux@foss.st.com>
> Signed-off-by: Torbjörn SVENSSON  <torbjorn.svensson@foss.st.com>
> ---
>   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"
>   );
>
  
Christophe Lyon Sept. 28, 2022, 11:55 a.m. UTC | #2
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?

>> 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.

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  <yvan.roux@foss.st.com>
>> Signed-off-by: Torbjörn SVENSSON  <torbjorn.svensson@foss.st.com>
>> ---
>>   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"
>>   );
  
Torbjorn SVENSSON Sept. 28, 2022, 1:39 p.m. UTC | #3
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  <yvan.roux@foss.st.com>
>>> Signed-off-by: Torbjörn SVENSSON  <torbjorn.svensson@foss.st.com>
>>> ---
>>>   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"
>>>   );
  
Christophe Lyon Sept. 28, 2022, 2:32 p.m. UTC | #4
On 9/28/22 15:39, Torbjorn SVENSSON wrote:
> 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.
> 

Thanks, that makes sense.

>>>> 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?
> 
Yeah, agreed, I just meant to say a linker patch in addition to this one 
is probably not worth the effort.

Christophe

> 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  <yvan.roux@foss.st.com>
>>>> Signed-off-by: Torbjörn SVENSSON  <torbjorn.svensson@foss.st.com>
>>>> ---
>>>>   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"
>>>>   );
  
Kyrylo Tkachov Oct. 5, 2022, 9:51 a.m. UTC | #5
Hi Torbjörn,

> -----Original Message-----
> From: Torbjorn SVENSSON <torbjorn.svensson@foss.st.com>
> Sent: Wednesday, October 5, 2022 10:28 AM
> To: Kyrylo Tkachov <Kyrylo.Tkachov@arm.com>
> Cc: Yvan Roux <yvan.roux@foss.st.com>
> Subject: Fwd: PING^1 [PATCH] testsuite: 'b' instruction can't do long enough
> jumps
> 
> Hi Kyrill,
> 
> I checked with Richard Sandiford if he could review this patch, but he
> pointed to you.
> Do you think that you can take a look it?

This is ok. I don't think it changes any of the things we want to actually test for in these cases.
Thanks,
Kyrill

> 
> Thank you!
> 
> Kind regards,
> Torbjörn
> 
> 
> -------- Forwarded Message --------
> Subject: PING^1 [PATCH] testsuite: 'b' instruction can't do long enough
> jumps
> Date: Wed, 28 Sep 2022 11:17:13 +0200
> From: Torbjorn SVENSSON <torbjorn.svensson@foss.st.com>
> To: gcc-patches@gcc.gnu.org
> CC: yvan.roux@foss.st.com, ro@CeBiTec.Uni-Bielefeld.DE,
> mikestump@comcast.net, kyrylo.tkachov@arm.com
> 
> 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
> > 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
> >
> > 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  <yvan.roux@foss.st.com>
> > Signed-off-by: Torbjörn SVENSSON  <torbjorn.svensson@foss.st.com>
> > ---
> >   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"
> >   );
> >
  
Torbjorn SVENSSON Oct. 5, 2022, 10:03 a.m. UTC | #6
On 2022-10-05 11:51, Kyrylo Tkachov wrote:
> Hi Torbjörn,
> 
>> -----Original Message-----
>> From: Torbjorn SVENSSON <torbjorn.svensson@foss.st.com>
>> Sent: Wednesday, October 5, 2022 10:28 AM
>> To: Kyrylo Tkachov <Kyrylo.Tkachov@arm.com>
>> Cc: Yvan Roux <yvan.roux@foss.st.com>
>> Subject: Fwd: PING^1 [PATCH] testsuite: 'b' instruction can't do long enough
>> jumps
>>
>> Hi Kyrill,
>>
>> I checked with Richard Sandiford if he could review this patch, but he
>> pointed to you.
>> Do you think that you can take a look it?
> 
> This is ok. I don't think it changes any of the things we want to actually test for in these cases.
> Thanks,
> Kyrill

Thank you!
Pushed to master branch 1a46a0a8b30405ea353a758971634dabeee89eaf.

Kind regards,
Torbjörn
  

Patch

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"
 );