0007-xtensa-add-.note.GNU-stack-section-on-linux.patch 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. From 4958020ecc85a30c52544deaf3c017cea82a0fb0 Mon Sep 17 00:00:00 2001
  2. From: Max Filippov <jcmvbkbc@gmail.com>
  3. Date: Thu, 2 Mar 2023 09:45:41 -0800
  4. Subject: [PATCH] xtensa: add .note.GNU-stack section on linux
  5. gcc/
  6. * config/xtensa/linux.h (TARGET_ASM_FILE_END): New macro.
  7. libgcc/
  8. * config/xtensa/crti.S: Add .note.GNU-stack section on linux.
  9. * config/xtensa/crtn.S: Likewise.
  10. * config/xtensa/lib1funcs.S: Likewise.
  11. * config/xtensa/lib2funcs.S: Likewise.
  12. Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
  13. Signed-off-by: Waldemar Brodkorb <wbx@openadk.org>
  14. Upstream: https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=6360bf9a2d08f08c151464c77c0da53cd702ff25
  15. ---
  16. gcc/config/xtensa/linux.h | 1 +
  17. libgcc/config/xtensa/crti.S | 6 ++++++
  18. libgcc/config/xtensa/crtn.S | 6 ++++++
  19. libgcc/config/xtensa/lib1funcs.S | 6 ++++++
  20. libgcc/config/xtensa/lib2funcs.S | 6 ++++++
  21. 5 files changed, 25 insertions(+)
  22. diff --git a/gcc/config/xtensa/linux.h b/gcc/config/xtensa/linux.h
  23. index 468a48489e7..a69e38c58ee 100644
  24. --- a/gcc/config/xtensa/linux.h
  25. +++ b/gcc/config/xtensa/linux.h
  26. @@ -69,3 +69,4 @@ along with GCC; see the file COPYING3. If not see
  27. #undef DBX_REGISTER_NUMBER
  28. +#define TARGET_ASM_FILE_END file_end_indicate_exec_stack
  29. diff --git a/libgcc/config/xtensa/crti.S b/libgcc/config/xtensa/crti.S
  30. index 87a66e32e4a..40dd8c0dbc2 100644
  31. --- a/libgcc/config/xtensa/crti.S
  32. +++ b/libgcc/config/xtensa/crti.S
  33. @@ -26,6 +26,12 @@
  34. #include "xtensa-config.h"
  35. +/* An executable stack is *not* required for these functions. */
  36. +#if defined(__ELF__) && defined(__linux__)
  37. +.section .note.GNU-stack,"",%progbits
  38. +.previous
  39. +#endif
  40. +
  41. .section .init
  42. .globl _init
  43. .type _init,@function
  44. diff --git a/libgcc/config/xtensa/crtn.S b/libgcc/config/xtensa/crtn.S
  45. index 8d2c2b1f22b..9d29f8fce1a 100644
  46. --- a/libgcc/config/xtensa/crtn.S
  47. +++ b/libgcc/config/xtensa/crtn.S
  48. @@ -27,6 +27,12 @@
  49. #include "xtensa-config.h"
  50. +/* An executable stack is *not* required for these functions. */
  51. +#if defined(__ELF__) && defined(__linux__)
  52. +.section .note.GNU-stack,"",%progbits
  53. +.previous
  54. +#endif
  55. +
  56. .section .init
  57. #if XCHAL_HAVE_WINDOWED && !__XTENSA_CALL0_ABI__
  58. retw
  59. diff --git a/libgcc/config/xtensa/lib1funcs.S b/libgcc/config/xtensa/lib1funcs.S
  60. index a482a6eefc8..5245d7ad8ad 100644
  61. --- a/libgcc/config/xtensa/lib1funcs.S
  62. +++ b/libgcc/config/xtensa/lib1funcs.S
  63. @@ -25,6 +25,12 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  64. #include "xtensa-config.h"
  65. +/* An executable stack is *not* required for these functions. */
  66. +#if defined(__ELF__) && defined(__linux__)
  67. +.section .note.GNU-stack,"",%progbits
  68. +.previous
  69. +#endif
  70. +
  71. /* Define macros for the ABS and ADDX* instructions to handle cases
  72. where they are not included in the Xtensa processor configuration. */
  73. diff --git a/libgcc/config/xtensa/lib2funcs.S b/libgcc/config/xtensa/lib2funcs.S
  74. index 36938c84924..a574a45fa68 100644
  75. --- a/libgcc/config/xtensa/lib2funcs.S
  76. +++ b/libgcc/config/xtensa/lib2funcs.S
  77. @@ -25,6 +25,12 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  78. #include "xtensa-config.h"
  79. +/* An executable stack is *not* required for these functions. */
  80. +#if defined(__ELF__) && defined(__linux__)
  81. +.section .note.GNU-stack,"",%progbits
  82. +.previous
  83. +#endif
  84. +
  85. /* __xtensa_libgcc_window_spill: This function flushes out all but the
  86. current register window. This is used to set up the stack so that
  87. arbitrary frames can be accessed. */
  88. --
  89. 2.39.2