[16/22] aarch64: libgcc: add GCS marking to asm

Message ID 20241023110528.487830-17-yury.khrustalev@arm.com
State Committed
Commit d8374290e5780621c5faeffcce3d2899da5d5bef
Headers
Series aarch64: Add support for Guarded Control Stack extension |

Commit Message

Yury Khrustalev Oct. 23, 2024, 11:05 a.m. UTC
  From: Szabolcs Nagy <szabolcs.nagy@arm.com>

libgcc/ChangeLog:

	* config/aarch64/aarch64-asm.h (FEATURE_1_GCS): Define.
	(GCS_FLAG): Define if GCS is enabled.
	(GNU_PROPERTY): Add GCS_FLAG.
---
 libgcc/config/aarch64/aarch64-asm.h | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)
  

Comments

Richard Sandiford Oct. 24, 2024, 4:31 p.m. UTC | #1
Yury Khrustalev <yury.khrustalev@arm.com> writes:
> From: Szabolcs Nagy <szabolcs.nagy@arm.com>
>
> libgcc/ChangeLog:
>
> 	* config/aarch64/aarch64-asm.h (FEATURE_1_GCS): Define.
> 	(GCS_FLAG): Define if GCS is enabled.
> 	(GNU_PROPERTY): Add GCS_FLAG.

This might be a daft question, but don't we also want to use the
new build attributes, where supported?  Or is that handled separately?

Same question for the other libraries.

Thanks,
Richard

> ---
>  libgcc/config/aarch64/aarch64-asm.h | 16 ++++++++++++++--
>  1 file changed, 14 insertions(+), 2 deletions(-)
>
> diff --git a/libgcc/config/aarch64/aarch64-asm.h b/libgcc/config/aarch64/aarch64-asm.h
> index d8ab91d52f1..f7bd225f7a4 100644
> --- a/libgcc/config/aarch64/aarch64-asm.h
> +++ b/libgcc/config/aarch64/aarch64-asm.h
> @@ -22,6 +22,9 @@
>     see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
>     <http://www.gnu.org/licenses/>.  */
>  
> +#ifndef AARCH64_ASM_H
> +#define AARCH64_ASM_H
> +
>  #include "auto-target.h"
>  
>  #define L(label) .L ## label
> @@ -38,6 +41,7 @@
>  #define FEATURE_1_AND 0xc0000000
>  #define FEATURE_1_BTI 1
>  #define FEATURE_1_PAC 2
> +#define FEATURE_1_GCS 4
>  
>  /* Supported features based on the code generation options.  */
>  #if defined(__ARM_FEATURE_BTI_DEFAULT)
> @@ -58,6 +62,12 @@
>  # define AUTIASP
>  #endif
>  
> +#if __ARM_FEATURE_GCS_DEFAULT
> +# define GCS_FLAG FEATURE_1_GCS
> +#else
> +# define GCS_FLAG 0
> +#endif
> +
>  #ifdef __ELF__
>  #define HIDDEN(name) .hidden name
>  #define SYMBOL_SIZE(name) .size name, .-name
> @@ -88,8 +98,8 @@
>  .previous
>  
>  /* Add GNU property note if built with branch protection.  */
> -# if (BTI_FLAG|PAC_FLAG) != 0
> -GNU_PROPERTY (FEATURE_1_AND, BTI_FLAG|PAC_FLAG)
> +# if (BTI_FLAG|PAC_FLAG|GCS_FLAG) != 0
> +GNU_PROPERTY (FEATURE_1_AND, BTI_FLAG|PAC_FLAG|GCS_FLAG)
>  # endif
>  #endif
>  
> @@ -106,3 +116,5 @@ GNU_PROPERTY (FEATURE_1_AND, BTI_FLAG|PAC_FLAG)
>  #define END(name) \
>    .cfi_endproc;		\
>    SYMBOL_SIZE(name)
> +
> +#endif
  
Yury Khrustalev Oct. 29, 2024, 1:46 p.m. UTC | #2
On Thu, Oct 24, 2024 at 05:31:58PM +0100, Richard Sandiford wrote:
> Yury Khrustalev <yury.khrustalev@arm.com> writes:
> > From: Szabolcs Nagy <szabolcs.nagy@arm.com>
> >
> > libgcc/ChangeLog:
> >
> > 	* config/aarch64/aarch64-asm.h (FEATURE_1_GCS): Define.
> > 	(GCS_FLAG): Define if GCS is enabled.
> > 	(GNU_PROPERTY): Add GCS_FLAG.
> 
> This might be a daft question, but don't we also want to use the
> new build attributes, where supported?  Or is that handled separately?
> 
> Same question for the other libraries.

The new build attributes will be handled separately as BA support can
be seen as orthogonal to GCS.

Thanks,
Yury
  

Patch

diff --git a/libgcc/config/aarch64/aarch64-asm.h b/libgcc/config/aarch64/aarch64-asm.h
index d8ab91d52f1..f7bd225f7a4 100644
--- a/libgcc/config/aarch64/aarch64-asm.h
+++ b/libgcc/config/aarch64/aarch64-asm.h
@@ -22,6 +22,9 @@ 
    see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
+#ifndef AARCH64_ASM_H
+#define AARCH64_ASM_H
+
 #include "auto-target.h"
 
 #define L(label) .L ## label
@@ -38,6 +41,7 @@ 
 #define FEATURE_1_AND 0xc0000000
 #define FEATURE_1_BTI 1
 #define FEATURE_1_PAC 2
+#define FEATURE_1_GCS 4
 
 /* Supported features based on the code generation options.  */
 #if defined(__ARM_FEATURE_BTI_DEFAULT)
@@ -58,6 +62,12 @@ 
 # define AUTIASP
 #endif
 
+#if __ARM_FEATURE_GCS_DEFAULT
+# define GCS_FLAG FEATURE_1_GCS
+#else
+# define GCS_FLAG 0
+#endif
+
 #ifdef __ELF__
 #define HIDDEN(name) .hidden name
 #define SYMBOL_SIZE(name) .size name, .-name
@@ -88,8 +98,8 @@ 
 .previous
 
 /* Add GNU property note if built with branch protection.  */
-# if (BTI_FLAG|PAC_FLAG) != 0
-GNU_PROPERTY (FEATURE_1_AND, BTI_FLAG|PAC_FLAG)
+# if (BTI_FLAG|PAC_FLAG|GCS_FLAG) != 0
+GNU_PROPERTY (FEATURE_1_AND, BTI_FLAG|PAC_FLAG|GCS_FLAG)
 # endif
 #endif
 
@@ -106,3 +116,5 @@  GNU_PROPERTY (FEATURE_1_AND, BTI_FLAG|PAC_FLAG)
 #define END(name) \
   .cfi_endproc;		\
   SYMBOL_SIZE(name)
+
+#endif