aarch64: libgcc: Cleanup ELF marking in asm

Message ID 20240130145435.1267286-1-szabolcs.nagy@arm.com
State Committed
Commit d85c17a2b628b7e783716ac376bdb60ddc2afb9a
Headers
Series aarch64: libgcc: Cleanup ELF marking in asm |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gcc_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gcc_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gcc_check--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gcc_check--master-aarch64 success Testing passed

Commit Message

Szabolcs Nagy Jan. 30, 2024, 2:54 p.m. UTC
  Use aarch64-asm.h in asm code consistently, this was started in

  commit c608ada288ced0268bbbbc1fd4136f56c34b24d4
  Author:     Zac Walker <zacwalker@microsoft.com>
  CommitDate: 2024-01-23 15:32:30 +0000

  Ifdef `.hidden`, `.type`, and `.size` pseudo-ops for `aarch64-w64-mingw32` target

But that commit failed to remove some existing markings from asm files,
which means some objects got double marked with gnu property notes.

libgcc/ChangeLog:

	* config/aarch64/crti.S: Remove stack marking.
	* config/aarch64/crtn.S: Remove stack marking, include aarch64-asm.h
	* config/aarch64/lse.S: Remove stack and GNU property markings.
---
 libgcc/config/aarch64/crti.S |  6 ------
 libgcc/config/aarch64/crtn.S |  6 +-----
 libgcc/config/aarch64/lse.S  | 40 ------------------------------------
 3 files changed, 1 insertion(+), 51 deletions(-)
  

Comments

Richard Sandiford Jan. 31, 2024, 8:42 p.m. UTC | #1
Szabolcs Nagy <szabolcs.nagy@arm.com> writes:
> Use aarch64-asm.h in asm code consistently, this was started in
>
>   commit c608ada288ced0268bbbbc1fd4136f56c34b24d4
>   Author:     Zac Walker <zacwalker@microsoft.com>
>   CommitDate: 2024-01-23 15:32:30 +0000
>
>   Ifdef `.hidden`, `.type`, and `.size` pseudo-ops for `aarch64-w64-mingw32` target
>
> But that commit failed to remove some existing markings from asm files,
> which means some objects got double marked with gnu property notes.
>
> libgcc/ChangeLog:
>
> 	* config/aarch64/crti.S: Remove stack marking.
> 	* config/aarch64/crtn.S: Remove stack marking, include aarch64-asm.h
> 	* config/aarch64/lse.S: Remove stack and GNU property markings.

OK, thanks.

Richard

> ---
>  libgcc/config/aarch64/crti.S |  6 ------
>  libgcc/config/aarch64/crtn.S |  6 +-----
>  libgcc/config/aarch64/lse.S  | 40 ------------------------------------
>  3 files changed, 1 insertion(+), 51 deletions(-)
>
> diff --git a/libgcc/config/aarch64/crti.S b/libgcc/config/aarch64/crti.S
> index b6805b86421..52ca1bb56d6 100644
> --- a/libgcc/config/aarch64/crti.S
> +++ b/libgcc/config/aarch64/crti.S
> @@ -23,12 +23,6 @@
>  
>  #include "aarch64-asm.h"
>  
> -/* An executable stack is *not* required for these functions.  */
> -#if defined(__ELF__) && defined(__linux__)
> -.section .note.GNU-stack,"",%progbits
> -.previous
> -#endif
> -
>  # This file creates a stack frame for the contents of the .fini and
>  # .init sections.  Users may put any desired instructions in those
>  # sections.
> diff --git a/libgcc/config/aarch64/crtn.S b/libgcc/config/aarch64/crtn.S
> index 59f2441032a..67bcfab8564 100644
> --- a/libgcc/config/aarch64/crtn.S
> +++ b/libgcc/config/aarch64/crtn.S
> @@ -21,11 +21,7 @@
>  # see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
>  # <http://www.gnu.org/licenses/>.
>  
> -/* An executable stack is *not* required for these functions.  */
> -#if defined(__ELF__) && defined(__linux__)
> -.section .note.GNU-stack,"",%progbits
> -.previous
> -#endif
> +#include "aarch64-asm.h"
>  
>  # This file just makes sure that the .fini and .init sections do in
>  # fact return.  Users may put any desired instructions in those sections.
> diff --git a/libgcc/config/aarch64/lse.S b/libgcc/config/aarch64/lse.S
> index cee1e88c6a4..ecef47086c6 100644
> --- a/libgcc/config/aarch64/lse.S
> +++ b/libgcc/config/aarch64/lse.S
> @@ -315,43 +315,3 @@ STARTFN	NAME(LDNM)
>  
>  ENDFN	NAME(LDNM)
>  #endif
> -
> -/* GNU_PROPERTY_AARCH64_* macros from elf.h for use in asm code.  */
> -#define FEATURE_1_AND 0xc0000000
> -#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";	\
> -  .p2align 3;				\
> -  .word 4;				\
> -  .word 16;				\
> -  .word 5;				\
> -  .asciz "GNU";				\
> -  .word type;				\
> -  .word 4;				\
> -  .word value;				\
> -  .word 0;
> -
> -#if defined(__linux__) || defined(__FreeBSD__)
> -.section .note.GNU-stack, "", %progbits
> -
> -/* Add GNU property note if built with branch protection.  */
> -# if (BTI_FLAG|PAC_FLAG) != 0
> -GNU_PROPERTY (FEATURE_1_AND, BTI_FLAG|PAC_FLAG)
> -# endif
> -#endif
  

Patch

diff --git a/libgcc/config/aarch64/crti.S b/libgcc/config/aarch64/crti.S
index b6805b86421..52ca1bb56d6 100644
--- a/libgcc/config/aarch64/crti.S
+++ b/libgcc/config/aarch64/crti.S
@@ -23,12 +23,6 @@ 
 
 #include "aarch64-asm.h"
 
-/* An executable stack is *not* required for these functions.  */
-#if defined(__ELF__) && defined(__linux__)
-.section .note.GNU-stack,"",%progbits
-.previous
-#endif
-
 # This file creates a stack frame for the contents of the .fini and
 # .init sections.  Users may put any desired instructions in those
 # sections.
diff --git a/libgcc/config/aarch64/crtn.S b/libgcc/config/aarch64/crtn.S
index 59f2441032a..67bcfab8564 100644
--- a/libgcc/config/aarch64/crtn.S
+++ b/libgcc/config/aarch64/crtn.S
@@ -21,11 +21,7 @@ 
 # see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 # <http://www.gnu.org/licenses/>.
 
-/* An executable stack is *not* required for these functions.  */
-#if defined(__ELF__) && defined(__linux__)
-.section .note.GNU-stack,"",%progbits
-.previous
-#endif
+#include "aarch64-asm.h"
 
 # This file just makes sure that the .fini and .init sections do in
 # fact return.  Users may put any desired instructions in those sections.
diff --git a/libgcc/config/aarch64/lse.S b/libgcc/config/aarch64/lse.S
index cee1e88c6a4..ecef47086c6 100644
--- a/libgcc/config/aarch64/lse.S
+++ b/libgcc/config/aarch64/lse.S
@@ -315,43 +315,3 @@  STARTFN	NAME(LDNM)
 
 ENDFN	NAME(LDNM)
 #endif
-
-/* GNU_PROPERTY_AARCH64_* macros from elf.h for use in asm code.  */
-#define FEATURE_1_AND 0xc0000000
-#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";	\
-  .p2align 3;				\
-  .word 4;				\
-  .word 16;				\
-  .word 5;				\
-  .asciz "GNU";				\
-  .word type;				\
-  .word 4;				\
-  .word value;				\
-  .word 0;
-
-#if defined(__linux__) || defined(__FreeBSD__)
-.section .note.GNU-stack, "", %progbits
-
-/* Add GNU property note if built with branch protection.  */
-# if (BTI_FLAG|PAC_FLAG) != 0
-GNU_PROPERTY (FEATURE_1_AND, BTI_FLAG|PAC_FLAG)
-# endif
-#endif