public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] libc: arm: fix setjmp abi non-conformance
@ 2022-12-13 14:51 Victor L. Do Nascimento
  2022-12-13 15:54 ` Richard Earnshaw
  2023-01-25 13:30 ` Mike Frysinger
  0 siblings, 2 replies; 7+ messages in thread
From: Victor L. Do Nascimento @ 2022-12-13 14:51 UTC (permalink / raw)
  To: newlib; +Cc: richard.earnshaw

As per the arm Procedure Call Standard for the Arm Architecture
section 6.1.2 [1], VFP registers s16-s31 (d8-d15, q4-q7) must be
preserved across subroutine calls.

The current setjmp/longjmp implementations preserve only the core
registers, with the jump buffer size too small to store the required
co-processor registers.

In accordance with the C Library ABI for the Arm Architecture
section 6.11 [2], this patch sets _JBTYPE to long long adjusting
_JBLEN to 20.

It also emits vfp load/store instructions depending on architectural
support, predicated at compile time on ACLE feature-test macros.

[1] https://github.com/ARM-software/abi-aa/blob/main/aapcs32/aapcs32.rst
[2] https://github.com/ARM-software/abi-aa/blob/main/clibabi32/clibabi32.rst
---
 COPYING.NEWLIB                       |  2 +-
 newlib/libc/include/machine/setjmp.h |  8 ++-
 newlib/libc/machine/arm/setjmp.S     | 74 +++++++++++++++-------------
 3 files changed, 46 insertions(+), 38 deletions(-)

diff --git a/COPYING.NEWLIB b/COPYING.NEWLIB
index 2d1473639..d54ed293d 100644
--- a/COPYING.NEWLIB
+++ b/COPYING.NEWLIB
@@ -762,7 +762,7 @@ SUCH DAMAGE.
 
 (35) - Arm Ltd
 
- Copyright (c) 2009-2018 Arm Ltd
+ Copyright (c) 2009-2022 Arm Ltd
  All rights reserved.
  
  Redistribution and use in source and binary forms, with or without
diff --git a/newlib/libc/include/machine/setjmp.h b/newlib/libc/include/machine/setjmp.h
index 53878a03d..29b76cec1 100644
--- a/newlib/libc/include/machine/setjmp.h
+++ b/newlib/libc/include/machine/setjmp.h
@@ -12,9 +12,13 @@ _BEGIN_STD_C
 #if defined(__arm__) || defined(__thumb__)
 /*
  * All callee preserved registers:
- * v1 - v7, fp, ip, sp, lr, f4, f5, f6, f7
+ *  core registers:
+ *   r4 - r10, fp, sp, lr
+ *  VFP registers (architectural support dependent):
+ *   d8 - d15
  */
-#define _JBLEN 23
+#define _JBLEN 20
+#define _JBTYPE long long
 #endif
 
 #if defined(__aarch64__)
diff --git a/newlib/libc/machine/arm/setjmp.S b/newlib/libc/machine/arm/setjmp.S
index 21d6ff9e7..4cf0a8e3f 100644
--- a/newlib/libc/machine/arm/setjmp.S
+++ b/newlib/libc/machine/arm/setjmp.S
@@ -27,34 +27,34 @@
    The interworking scheme expects functions to use a BX instruction
    to return control to their parent.  Since we need this code to work
    in both interworked and non-interworked environments as well as with
-   older processors which do not have the BX instruction we do the 
+   older processors which do not have the BX instruction we do the
    following:
 	Test the return address.
 	If the bottom bit is clear perform an "old style" function exit.
 	(We know that we are in ARM mode and returning to an ARM mode caller).
 	Otherwise use the BX instruction to perform the function exit.
 
-   We know that we will never attempt to perform the BX instruction on 
-   an older processor, because that kind of processor will never be 
-   interworked, and a return address with the bottom bit set will never 
+   We know that we will never attempt to perform the BX instruction on
+   an older processor, because that kind of processor will never be
+   interworked, and a return address with the bottom bit set will never
    be generated.
 
    In addition, we do not actually assemble the BX instruction as this would
    require us to tell the assembler that the processor is an ARM7TDMI and
    it would store this information in the binary.  We want this binary to be
    able to be linked with binaries compiled for older processors however, so
-   we do not want such information stored there.  
+   we do not want such information stored there.
 
    If we are running using the APCS-26 convention however, then we never
-   test the bottom bit, because this is part of the processor status.  
-   Instead we just do a normal return, since we know that we cannot be 
+   test the bottom bit, because this is part of the processor status.
+   Instead we just do a normal return, since we know that we cannot be
    returning to a Thumb caller - the Thumb does not support APCS-26.
-	
-   Function entry is much simpler.  If we are compiling for the Thumb we 
+
+   Function entry is much simpler.  If we are compiling for the Thumb we
    just switch into ARM mode and then drop through into the rest of the
    function.  The function exit code will take care of the restore to
    Thumb mode.
-   
+
    For Thumb-2 do everything in Thumb mode.  */
 
 	.syntax unified
@@ -115,15 +115,15 @@ SYM (longjmp):
 #else
 #define RET	tst		lr, #1; \
 	        moveq		pc, lr ; \
-.word           0xe12fff1e	/* bx lr */
+.inst           0xe12fff1e	/* bx lr */
 #endif
 
 #ifdef __thumb2__
-.macro COND where when 
+.macro COND where when
 	i\where	\when
 .endm
 #else
-.macro COND where when 
+.macro COND where when
 .endm
 #endif
 
@@ -140,7 +140,7 @@ SYM (longjmp):
 .macro PROLOGUE name
 	.code 16
 	bx	pc
-	nop	
+	nop
 	.code 32
 SYM (.arm_start_of.\name):
 .endm
@@ -149,7 +149,7 @@ SYM (.arm_start_of.\name):
 .macro PROLOGUE name
 .endm
 #endif
-	
+
 .macro FUNC_START name
 	.text
 	.align 2
@@ -164,61 +164,65 @@ SYM (\name):
 	RET
 	SIZE (\name)
 .endm
-	
+
 /* --------------------------------------------------------------------
-                 int setjmp (jmp_buf); 
+                 int setjmp (jmp_buf);
    -------------------------------------------------------------------- */
-	
+
 	FUNC_START setjmp
 
 	/* Save all the callee-preserved registers into the jump buffer.  */
 #ifdef __thumb2__
 	mov		ip, sp
-	stmea		a1!, { v1-v7, fp, ip, lr }
+	stmia		r0!, { r4-r10, fp, ip, lr }
 #else
-	stmea		a1!, { v1-v7, fp, ip, sp, lr }
+	stmia		r0!, { r4-r10, fp, sp, lr }
+#endif
+#if defined __ARM_FP || defined __ARM_FEATURE_MVE
+	vstm		r0, { d8-d15 }
 #endif
-	
+
 #if 0	/* Simulator does not cope with FP instructions yet.  */
 #ifndef __SOFTFP__
 	/* Save the floating point registers.  */
 	sfmea		f4, 4, [a1]
 #endif
-#endif		
+#endif
 	/* When setting up the jump buffer return 0.  */
-	mov		a1, #0
+	mov		r0, #0
 
 	FUNC_END setjmp
-	
+
 /* --------------------------------------------------------------------
 		volatile void longjmp (jmp_buf, int);
    -------------------------------------------------------------------- */
-	
+
 	FUNC_START longjmp
 
 	/* If we have stack extension code it ought to be handled here.  */
-	
+
 	/* Restore the registers, retrieving the state when setjmp() was called.  */
 #ifdef __thumb2__
-	ldmfd		a1!, { v1-v7, fp, ip, lr }
+	ldmia		r0!, { r4-r10, fp, ip, lr }
 	mov		sp, ip
 #else
-	ldmfd		a1!, { v1-v7, fp, ip, sp, lr }
+	ldmia		r0!, { r4-r10, fp, sp, lr }
+#endif
+#if defined __ARM_FP || defined __ARM_FEATURE_MVE
+	vldm		r0, { d8-d15 }
 #endif
-	
+
 #if 0	/* Simulator does not cope with FP instructions yet.  */
 #ifndef __SOFTFP__
 	/* Restore floating point registers as well.  */
 	lfmfd		f4, 4, [a1]
 #endif
-#endif	
+#endif
 	/* Put the return value into the integer result register.
-	   But if it is zero then return 1 instead.  */	
-	movs		a1, a2
-#ifdef __thumb2__
+	   But if it is zero then return 1 instead.  */
+	movs		r0, r1
 	it		eq
-#endif
-	moveq		a1, #1
+	moveq		r0, #1
 
 	FUNC_END longjmp
 #endif
-- 
2.36.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] libc: arm: fix setjmp abi non-conformance
  2022-12-13 14:51 [PATCH] libc: arm: fix setjmp abi non-conformance Victor L. Do Nascimento
@ 2022-12-13 15:54 ` Richard Earnshaw
  2023-01-25 13:30 ` Mike Frysinger
  1 sibling, 0 replies; 7+ messages in thread
From: Richard Earnshaw @ 2022-12-13 15:54 UTC (permalink / raw)
  To: Victor L. Do Nascimento, newlib; +Cc: richard.earnshaw



On 13/12/2022 14:51, Victor L. Do Nascimento wrote:
> As per the arm Procedure Call Standard for the Arm Architecture
> section 6.1.2 [1], VFP registers s16-s31 (d8-d15, q4-q7) must be
> preserved across subroutine calls.
> 
> The current setjmp/longjmp implementations preserve only the core
> registers, with the jump buffer size too small to store the required
> co-processor registers.
> 
> In accordance with the C Library ABI for the Arm Architecture
> section 6.11 [2], this patch sets _JBTYPE to long long adjusting
> _JBLEN to 20.
> 
> It also emits vfp load/store instructions depending on architectural
> support, predicated at compile time on ACLE feature-test macros.
> 

Pushed.

Would you mind writing a short entry for the top-level NEWS file, as 
this is technically an ABI break.  Just point out that the size and 
alignment of jmp_buf has been changed to conform with the ABI and to fix 
a bug with saving floating-point registers.

R.

> [1] https://github.com/ARM-software/abi-aa/blob/main/aapcs32/aapcs32.rst
> [2] https://github.com/ARM-software/abi-aa/blob/main/clibabi32/clibabi32.rst
> ---
>   COPYING.NEWLIB                       |  2 +-
>   newlib/libc/include/machine/setjmp.h |  8 ++-
>   newlib/libc/machine/arm/setjmp.S     | 74 +++++++++++++++-------------
>   3 files changed, 46 insertions(+), 38 deletions(-)
> 
> diff --git a/COPYING.NEWLIB b/COPYING.NEWLIB
> index 2d1473639..d54ed293d 100644
> --- a/COPYING.NEWLIB
> +++ b/COPYING.NEWLIB
> @@ -762,7 +762,7 @@ SUCH DAMAGE.
>   
>   (35) - Arm Ltd
>   
> - Copyright (c) 2009-2018 Arm Ltd
> + Copyright (c) 2009-2022 Arm Ltd
>    All rights reserved.
>    
>    Redistribution and use in source and binary forms, with or without
> diff --git a/newlib/libc/include/machine/setjmp.h b/newlib/libc/include/machine/setjmp.h
> index 53878a03d..29b76cec1 100644
> --- a/newlib/libc/include/machine/setjmp.h
> +++ b/newlib/libc/include/machine/setjmp.h
> @@ -12,9 +12,13 @@ _BEGIN_STD_C
>   #if defined(__arm__) || defined(__thumb__)
>   /*
>    * All callee preserved registers:
> - * v1 - v7, fp, ip, sp, lr, f4, f5, f6, f7
> + *  core registers:
> + *   r4 - r10, fp, sp, lr
> + *  VFP registers (architectural support dependent):
> + *   d8 - d15
>    */
> -#define _JBLEN 23
> +#define _JBLEN 20
> +#define _JBTYPE long long
>   #endif
>   
>   #if defined(__aarch64__)
> diff --git a/newlib/libc/machine/arm/setjmp.S b/newlib/libc/machine/arm/setjmp.S
> index 21d6ff9e7..4cf0a8e3f 100644
> --- a/newlib/libc/machine/arm/setjmp.S
> +++ b/newlib/libc/machine/arm/setjmp.S
> @@ -27,34 +27,34 @@
>      The interworking scheme expects functions to use a BX instruction
>      to return control to their parent.  Since we need this code to work
>      in both interworked and non-interworked environments as well as with
> -   older processors which do not have the BX instruction we do the
> +   older processors which do not have the BX instruction we do the
>      following:
>   	Test the return address.
>   	If the bottom bit is clear perform an "old style" function exit.
>   	(We know that we are in ARM mode and returning to an ARM mode caller).
>   	Otherwise use the BX instruction to perform the function exit.
>   
> -   We know that we will never attempt to perform the BX instruction on
> -   an older processor, because that kind of processor will never be
> -   interworked, and a return address with the bottom bit set will never
> +   We know that we will never attempt to perform the BX instruction on
> +   an older processor, because that kind of processor will never be
> +   interworked, and a return address with the bottom bit set will never
>      be generated.
>   
>      In addition, we do not actually assemble the BX instruction as this would
>      require us to tell the assembler that the processor is an ARM7TDMI and
>      it would store this information in the binary.  We want this binary to be
>      able to be linked with binaries compiled for older processors however, so
> -   we do not want such information stored there.
> +   we do not want such information stored there.
>   
>      If we are running using the APCS-26 convention however, then we never
> -   test the bottom bit, because this is part of the processor status.
> -   Instead we just do a normal return, since we know that we cannot be
> +   test the bottom bit, because this is part of the processor status.
> +   Instead we just do a normal return, since we know that we cannot be
>      returning to a Thumb caller - the Thumb does not support APCS-26.
> -	
> -   Function entry is much simpler.  If we are compiling for the Thumb we
> +
> +   Function entry is much simpler.  If we are compiling for the Thumb we
>      just switch into ARM mode and then drop through into the rest of the
>      function.  The function exit code will take care of the restore to
>      Thumb mode.
> -
> +
>      For Thumb-2 do everything in Thumb mode.  */
>   
>   	.syntax unified
> @@ -115,15 +115,15 @@ SYM (longjmp):
>   #else
>   #define RET	tst		lr, #1; \
>   	        moveq		pc, lr ; \
> -.word           0xe12fff1e	/* bx lr */
> +.inst           0xe12fff1e	/* bx lr */
>   #endif
>   
>   #ifdef __thumb2__
> -.macro COND where when
> +.macro COND where when
>   	i\where	\when
>   .endm
>   #else
> -.macro COND where when
> +.macro COND where when
>   .endm
>   #endif
>   
> @@ -140,7 +140,7 @@ SYM (longjmp):
>   .macro PROLOGUE name
>   	.code 16
>   	bx	pc
> -	nop	
> +	nop
>   	.code 32
>   SYM (.arm_start_of.\name):
>   .endm
> @@ -149,7 +149,7 @@ SYM (.arm_start_of.\name):
>   .macro PROLOGUE name
>   .endm
>   #endif
> -	
> +
>   .macro FUNC_START name
>   	.text
>   	.align 2
> @@ -164,61 +164,65 @@ SYM (\name):
>   	RET
>   	SIZE (\name)
>   .endm
> -	
> +
>   /* --------------------------------------------------------------------
> -                 int setjmp (jmp_buf);
> +                 int setjmp (jmp_buf);
>      -------------------------------------------------------------------- */
> -	
> +
>   	FUNC_START setjmp
>   
>   	/* Save all the callee-preserved registers into the jump buffer.  */
>   #ifdef __thumb2__
>   	mov		ip, sp
> -	stmea		a1!, { v1-v7, fp, ip, lr }
> +	stmia		r0!, { r4-r10, fp, ip, lr }
>   #else
> -	stmea		a1!, { v1-v7, fp, ip, sp, lr }
> +	stmia		r0!, { r4-r10, fp, sp, lr }
> +#endif
> +#if defined __ARM_FP || defined __ARM_FEATURE_MVE
> +	vstm		r0, { d8-d15 }
>   #endif
> -	
> +
>   #if 0	/* Simulator does not cope with FP instructions yet.  */
>   #ifndef __SOFTFP__
>   	/* Save the floating point registers.  */
>   	sfmea		f4, 4, [a1]
>   #endif
> -#endif		
> +#endif
>   	/* When setting up the jump buffer return 0.  */
> -	mov		a1, #0
> +	mov		r0, #0
>   
>   	FUNC_END setjmp
> -	
> +
>   /* --------------------------------------------------------------------
>   		volatile void longjmp (jmp_buf, int);
>      -------------------------------------------------------------------- */
> -	
> +
>   	FUNC_START longjmp
>   
>   	/* If we have stack extension code it ought to be handled here.  */
> -	
> +
>   	/* Restore the registers, retrieving the state when setjmp() was called.  */
>   #ifdef __thumb2__
> -	ldmfd		a1!, { v1-v7, fp, ip, lr }
> +	ldmia		r0!, { r4-r10, fp, ip, lr }
>   	mov		sp, ip
>   #else
> -	ldmfd		a1!, { v1-v7, fp, ip, sp, lr }
> +	ldmia		r0!, { r4-r10, fp, sp, lr }
> +#endif
> +#if defined __ARM_FP || defined __ARM_FEATURE_MVE
> +	vldm		r0, { d8-d15 }
>   #endif
> -	
> +
>   #if 0	/* Simulator does not cope with FP instructions yet.  */
>   #ifndef __SOFTFP__
>   	/* Restore floating point registers as well.  */
>   	lfmfd		f4, 4, [a1]
>   #endif
> -#endif	
> +#endif
>   	/* Put the return value into the integer result register.
> -	   But if it is zero then return 1 instead.  */	
> -	movs		a1, a2
> -#ifdef __thumb2__
> +	   But if it is zero then return 1 instead.  */
> +	movs		r0, r1
>   	it		eq
> -#endif
> -	moveq		a1, #1
> +	moveq		r0, #1
>   
>   	FUNC_END longjmp
>   #endif

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] libc: arm: fix setjmp abi non-conformance
  2022-12-13 14:51 [PATCH] libc: arm: fix setjmp abi non-conformance Victor L. Do Nascimento
  2022-12-13 15:54 ` Richard Earnshaw
@ 2023-01-25 13:30 ` Mike Frysinger
  2023-02-03 13:09   ` Richard Earnshaw
  1 sibling, 1 reply; 7+ messages in thread
From: Mike Frysinger @ 2023-01-25 13:30 UTC (permalink / raw)
  To: Victor L. Do Nascimento; +Cc: newlib, richard.earnshaw

[-- Attachment #1: Type: text/plain, Size: 936 bytes --]

On 13 Dec 2022 14:51, Victor L. Do Nascimento wrote:
> As per the arm Procedure Call Standard for the Arm Architecture
> section 6.1.2 [1], VFP registers s16-s31 (d8-d15, q4-q7) must be
> preserved across subroutine calls.
> 
> The current setjmp/longjmp implementations preserve only the core
> registers, with the jump buffer size too small to store the required
> co-processor registers.
> 
> In accordance with the C Library ABI for the Arm Architecture
> section 6.11 [2], this patch sets _JBTYPE to long long adjusting
> _JBLEN to 20.
> 
> It also emits vfp load/store instructions depending on architectural
> support, predicated at compile time on ACLE feature-test macros.

this breaks building with GCC 11 and older:
https://bugs.gentoo.org/891589#c7

i don't think it was intentional that this only work with GCC 12+, or if
it was, that we want such requirements.  GCC 12 is less than a year old.
-mike

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] libc: arm: fix setjmp abi non-conformance
  2023-01-25 13:30 ` Mike Frysinger
@ 2023-02-03 13:09   ` Richard Earnshaw
  2023-02-07 15:24     ` Victor Do Nascimento
  0 siblings, 1 reply; 7+ messages in thread
From: Richard Earnshaw @ 2023-02-03 13:09 UTC (permalink / raw)
  To: Mike Frysinger, Victor L. Do Nascimento; +Cc: newlib, richard.earnshaw



On 25/01/2023 13:30, Mike Frysinger wrote:
> On 13 Dec 2022 14:51, Victor L. Do Nascimento wrote:
>> As per the arm Procedure Call Standard for the Arm Architecture
>> section 6.1.2 [1], VFP registers s16-s31 (d8-d15, q4-q7) must be
>> preserved across subroutine calls.
>>
>> The current setjmp/longjmp implementations preserve only the core
>> registers, with the jump buffer size too small to store the required
>> co-processor registers.
>>
>> In accordance with the C Library ABI for the Arm Architecture
>> section 6.11 [2], this patch sets _JBTYPE to long long adjusting
>> _JBLEN to 20.
>>
>> It also emits vfp load/store instructions depending on architectural
>> support, predicated at compile time on ACLE feature-test macros.
> 
> this breaks building with GCC 11 and older:
> https://bugs.gentoo.org/891589#c7
> 
> i don't think it was intentional that this only work with GCC 12+, or if
> it was, that we want such requirements.  GCC 12 is less than a year old.
> -mike

This has been fixed with commit c6e601de84ea9f2be2b026c609cc3c1fe82a3103.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] libc: arm: fix setjmp abi non-conformance
  2023-02-03 13:09   ` Richard Earnshaw
@ 2023-02-07 15:24     ` Victor Do Nascimento
  2023-02-07 15:30       ` Richard Earnshaw
  2023-02-07 21:45       ` Jeff Johnston
  0 siblings, 2 replies; 7+ messages in thread
From: Victor Do Nascimento @ 2023-02-07 15:24 UTC (permalink / raw)
  To: Richard Earnshaw, Mike Frysinger; +Cc: newlib, richard.earnshaw

Dear Richard (now also CCing the mailing list),

One of the folks over at the Gentoo bug discussion inquired about 
getting the patch back-ported to the latest source snapshot (where the 
problem originally presented itself), newlib-4.3.0.20230120.

Is that an option at all?

Cheers,
Victor

On 2/3/23 13:09, Richard Earnshaw wrote:
> 
> 
> On 25/01/2023 13:30, Mike Frysinger wrote:
>> On 13 Dec 2022 14:51, Victor L. Do Nascimento wrote:
>>> As per the arm Procedure Call Standard for the Arm Architecture
>>> section 6.1.2 [1], VFP registers s16-s31 (d8-d15, q4-q7) must be
>>> preserved across subroutine calls.
>>>
>>> The current setjmp/longjmp implementations preserve only the core
>>> registers, with the jump buffer size too small to store the required
>>> co-processor registers.
>>>
>>> In accordance with the C Library ABI for the Arm Architecture
>>> section 6.11 [2], this patch sets _JBTYPE to long long adjusting
>>> _JBLEN to 20.
>>>
>>> It also emits vfp load/store instructions depending on architectural
>>> support, predicated at compile time on ACLE feature-test macros.
>>
>> this breaks building with GCC 11 and older:
>> https://bugs.gentoo.org/891589#c7
>>
>> i don't think it was intentional that this only work with GCC 12+, or if
>> it was, that we want such requirements.  GCC 12 is less than a year old.
>> -mike
> 
> This has been fixed with commit c6e601de84ea9f2be2b026c609cc3c1fe82a3103.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] libc: arm: fix setjmp abi non-conformance
  2023-02-07 15:24     ` Victor Do Nascimento
@ 2023-02-07 15:30       ` Richard Earnshaw
  2023-02-07 21:45       ` Jeff Johnston
  1 sibling, 0 replies; 7+ messages in thread
From: Richard Earnshaw @ 2023-02-07 15:30 UTC (permalink / raw)
  To: Victor Do Nascimento, Mike Frysinger; +Cc: newlib, richard.earnshaw

Newlib doesn't maintain branches (we just tag the repo and make a 
snapshot public based on that), so there's nowhere this can be 
backported to.

Ultimately this is Jeff's (or Corinna's) call though.

R.

On 07/02/2023 15:24, Victor Do Nascimento wrote:
> Dear Richard (now also CCing the mailing list),
> 
> One of the folks over at the Gentoo bug discussion inquired about 
> getting the patch back-ported to the latest source snapshot (where the 
> problem originally presented itself), newlib-4.3.0.20230120.
> 
> Is that an option at all?
> 
> Cheers,
> Victor
> 
> On 2/3/23 13:09, Richard Earnshaw wrote:
>>
>>
>> On 25/01/2023 13:30, Mike Frysinger wrote:
>>> On 13 Dec 2022 14:51, Victor L. Do Nascimento wrote:
>>>> As per the arm Procedure Call Standard for the Arm Architecture
>>>> section 6.1.2 [1], VFP registers s16-s31 (d8-d15, q4-q7) must be
>>>> preserved across subroutine calls.
>>>>
>>>> The current setjmp/longjmp implementations preserve only the core
>>>> registers, with the jump buffer size too small to store the required
>>>> co-processor registers.
>>>>
>>>> In accordance with the C Library ABI for the Arm Architecture
>>>> section 6.11 [2], this patch sets _JBTYPE to long long adjusting
>>>> _JBLEN to 20.
>>>>
>>>> It also emits vfp load/store instructions depending on architectural
>>>> support, predicated at compile time on ACLE feature-test macros.
>>>
>>> this breaks building with GCC 11 and older:
>>> https://bugs.gentoo.org/891589#c7
>>>
>>> i don't think it was intentional that this only work with GCC 12+, or if
>>> it was, that we want such requirements.  GCC 12 is less than a year old.
>>> -mike
>>
>> This has been fixed with commit c6e601de84ea9f2be2b026c609cc3c1fe82a3103.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] libc: arm: fix setjmp abi non-conformance
  2023-02-07 15:24     ` Victor Do Nascimento
  2023-02-07 15:30       ` Richard Earnshaw
@ 2023-02-07 21:45       ` Jeff Johnston
  1 sibling, 0 replies; 7+ messages in thread
From: Jeff Johnston @ 2023-02-07 21:45 UTC (permalink / raw)
  To: Victor Do Nascimento
  Cc: Richard Earnshaw, Mike Frysinger, newlib, richard.earnshaw

[-- Attachment #1: Type: text/plain, Size: 1777 bytes --]

A new snapshot can be made.  There is also an issue with -idirafter not
being supported by a few platforms.  How urgent is this?  Can it
wait until the other issue is fixed?

-- Jeff J.

On Tue, Feb 7, 2023 at 10:25 AM Victor Do Nascimento <
Victor.DoNascimento@arm.com> wrote:

> Dear Richard (now also CCing the mailing list),
>
> One of the folks over at the Gentoo bug discussion inquired about
> getting the patch back-ported to the latest source snapshot (where the
> problem originally presented itself), newlib-4.3.0.20230120.
>
> Is that an option at all?
>
> Cheers,
> Victor
>
> On 2/3/23 13:09, Richard Earnshaw wrote:
> >
> >
> > On 25/01/2023 13:30, Mike Frysinger wrote:
> >> On 13 Dec 2022 14:51, Victor L. Do Nascimento wrote:
> >>> As per the arm Procedure Call Standard for the Arm Architecture
> >>> section 6.1.2 [1], VFP registers s16-s31 (d8-d15, q4-q7) must be
> >>> preserved across subroutine calls.
> >>>
> >>> The current setjmp/longjmp implementations preserve only the core
> >>> registers, with the jump buffer size too small to store the required
> >>> co-processor registers.
> >>>
> >>> In accordance with the C Library ABI for the Arm Architecture
> >>> section 6.11 [2], this patch sets _JBTYPE to long long adjusting
> >>> _JBLEN to 20.
> >>>
> >>> It also emits vfp load/store instructions depending on architectural
> >>> support, predicated at compile time on ACLE feature-test macros.
> >>
> >> this breaks building with GCC 11 and older:
> >> https://bugs.gentoo.org/891589#c7
> >>
> >> i don't think it was intentional that this only work with GCC 12+, or if
> >> it was, that we want such requirements.  GCC 12 is less than a year old.
> >> -mike
> >
> > This has been fixed with commit c6e601de84ea9f2be2b026c609cc3c1fe82a3103.
>
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-02-07 21:46 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-13 14:51 [PATCH] libc: arm: fix setjmp abi non-conformance Victor L. Do Nascimento
2022-12-13 15:54 ` Richard Earnshaw
2023-01-25 13:30 ` Mike Frysinger
2023-02-03 13:09   ` Richard Earnshaw
2023-02-07 15:24     ` Victor Do Nascimento
2023-02-07 15:30       ` Richard Earnshaw
2023-02-07 21:45       ` Jeff Johnston

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).