public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH 1/2] aarch64: add PAC GNU property note to libgcc lse.S
@ 2020-07-23 16:23 Szabolcs Nagy
  2020-07-24  9:15 ` Kyrylo Tkachov
  0 siblings, 1 reply; 2+ messages in thread
From: Szabolcs Nagy @ 2020-07-23 16:23 UTC (permalink / raw)
  To: gcc-patches

This note is not used anywhere currently but it is supposed to mark
objects if the return address is protected with PAC on the stack.
Since lse.S only has leaf functions the return address is never
saved on the stack so we can add the note.

The note is only added if pac-ret is enabled because it can cause
problems with old linkers and we don't have checks for that. This
can be changed later to be unconditional, for now it is consistent
with how gcc generates the notes.

libgcc/ChangeLog:

        * config/aarch64/lse.S: Add PAC property note.
---
 libgcc/config/aarch64/lse.S | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/libgcc/config/aarch64/lse.S b/libgcc/config/aarch64/lse.S
index 64691c601c1..aa3e3dc4f2d 100644
--- a/libgcc/config/aarch64/lse.S
+++ b/libgcc/config/aarch64/lse.S
@@ -283,6 +283,19 @@ ENDFN	NAME(LDNM)
 #define FEATURE_1_BTI 1
 #define FEATURE_1_PAC 2
 
+/* Supported features based on the code generation options.  */
+#if defined(__ARM_FEATURE_BTI_DEFAULT)
+# define BTI_FLAG FEATURE_1_BTI
+#else
+# define BTI_FLAG 0
+#endif
+
+#if __ARM_FEATURE_PAC_DEFAULT & 3
+# define PAC_FLAG FEATURE_1_PAC
+#else
+# define PAC_FLAG 0
+#endif
+
 /* Add a NT_GNU_PROPERTY_TYPE_0 note.  */
 #define GNU_PROPERTY(type, value)	\
   .section .note.gnu.property, "a";	\
@@ -300,7 +313,7 @@ ENDFN	NAME(LDNM)
 .section .note.GNU-stack, "", %progbits
 
 /* Add GNU property note if built with branch protection.  */
-# ifdef __ARM_FEATURE_BTI_DEFAULT
-GNU_PROPERTY (FEATURE_1_AND, FEATURE_1_BTI)
+# if (BTI_FLAG|PAC_FLAG) != 0
+GNU_PROPERTY (FEATURE_1_AND, BTI_FLAG|PAC_FLAG)
 # endif
 #endif
-- 
2.17.1


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

* RE: [PATCH 1/2] aarch64: add PAC GNU property note to libgcc lse.S
  2020-07-23 16:23 [PATCH 1/2] aarch64: add PAC GNU property note to libgcc lse.S Szabolcs Nagy
@ 2020-07-24  9:15 ` Kyrylo Tkachov
  0 siblings, 0 replies; 2+ messages in thread
From: Kyrylo Tkachov @ 2020-07-24  9:15 UTC (permalink / raw)
  To: Szabolcs Nagy, gcc-patches

Hi Szabolcs,

> -----Original Message-----
> From: Szabolcs Nagy <Szabolcs.Nagy@arm.com>
> Sent: 23 July 2020 17:24
> To: gcc-patches@gcc.gnu.org
> Cc: Kyrylo Tkachov <Kyrylo.Tkachov@arm.com>
> Subject: [PATCH 1/2] aarch64: add PAC GNU property note to libgcc lse.S
> 
> This note is not used anywhere currently but it is supposed to mark
> objects if the return address is protected with PAC on the stack.
> Since lse.S only has leaf functions the return address is never
> saved on the stack so we can add the note.
> 
> The note is only added if pac-ret is enabled because it can cause
> problems with old linkers and we don't have checks for that. This
> can be changed later to be unconditional, for now it is consistent
> with how gcc generates the notes.
> 

Ok.
Thanks,
Kyrill

> libgcc/ChangeLog:
> 
>         * config/aarch64/lse.S: Add PAC property note.
> ---
>  libgcc/config/aarch64/lse.S | 17 +++++++++++++++--
>  1 file changed, 15 insertions(+), 2 deletions(-)
> 
> diff --git a/libgcc/config/aarch64/lse.S b/libgcc/config/aarch64/lse.S
> index 64691c601c1..aa3e3dc4f2d 100644
> --- a/libgcc/config/aarch64/lse.S
> +++ b/libgcc/config/aarch64/lse.S
> @@ -283,6 +283,19 @@ ENDFN	NAME(LDNM)
>  #define FEATURE_1_BTI 1
>  #define FEATURE_1_PAC 2
> 
> +/* Supported features based on the code generation options.  */
> +#if defined(__ARM_FEATURE_BTI_DEFAULT)
> +# define BTI_FLAG FEATURE_1_BTI
> +#else
> +# define BTI_FLAG 0
> +#endif
> +
> +#if __ARM_FEATURE_PAC_DEFAULT & 3
> +# define PAC_FLAG FEATURE_1_PAC
> +#else
> +# define PAC_FLAG 0
> +#endif
> +
>  /* Add a NT_GNU_PROPERTY_TYPE_0 note.  */
>  #define GNU_PROPERTY(type, value)	\
>    .section .note.gnu.property, "a";	\
> @@ -300,7 +313,7 @@ ENDFN	NAME(LDNM)
>  .section .note.GNU-stack, "", %progbits
> 
>  /* Add GNU property note if built with branch protection.  */
> -# ifdef __ARM_FEATURE_BTI_DEFAULT
> -GNU_PROPERTY (FEATURE_1_AND, FEATURE_1_BTI)
> +# if (BTI_FLAG|PAC_FLAG) != 0
> +GNU_PROPERTY (FEATURE_1_AND, BTI_FLAG|PAC_FLAG)
>  # endif
>  #endif
> --
> 2.17.1


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

end of thread, other threads:[~2020-07-24  9:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-23 16:23 [PATCH 1/2] aarch64: add PAC GNU property note to libgcc lse.S Szabolcs Nagy
2020-07-24  9:15 ` Kyrylo Tkachov

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