summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta/recipes-devtools/clang/clang/0001-compiler-rt-AArch64-Add-GCS-property-in-assembly-fil.patch151
-rw-r--r--meta/recipes-devtools/clang/common.inc1
2 files changed, 152 insertions, 0 deletions
diff --git a/meta/recipes-devtools/clang/clang/0001-compiler-rt-AArch64-Add-GCS-property-in-assembly-fil.patch b/meta/recipes-devtools/clang/clang/0001-compiler-rt-AArch64-Add-GCS-property-in-assembly-fil.patch
new file mode 100644
index 0000000000..5935c42d90
--- /dev/null
+++ b/meta/recipes-devtools/clang/clang/0001-compiler-rt-AArch64-Add-GCS-property-in-assembly-fil.patch
@@ -0,0 +1,151 @@
1From 2d102880766a5e55e5d7b4f9a2fb106d7d1ee55c Mon Sep 17 00:00:00 2001
2From: =?UTF-8?q?Csan=C3=A1d=20Hajd=C3=BA?= <csanad.hajdu@arm.com>
3Date: Thu, 7 Aug 2025 16:40:36 +0200
4Subject: [PATCH] [compiler-rt][AArch64] Add GCS property in assembly files
5 (#152502)
6
7Only BTI and PAC properties were added previously.
8
9Fixes https://github.com/llvm/llvm-project/issues/152427.
10
11Upstream-Status: Backport [https://github.com/llvm/llvm-project/pull/152502]
12Signed-off-by: Khem Raj <raj.khem@gmail.com>
13---
14 compiler-rt/lib/builtins/aarch64/lse.S | 4 ++--
15 compiler-rt/lib/builtins/aarch64/sme-abi.S | 4 ++--
16 compiler-rt/lib/builtins/assembly.h | 18 +++++++++++++-----
17 .../lib/hwasan/hwasan_interceptors_vfork.S | 2 +-
18 compiler-rt/lib/hwasan/hwasan_setjmp_aarch64.S | 2 +-
19 .../lib/hwasan/hwasan_tag_mismatch_aarch64.S | 2 +-
20 ...zer_common_interceptors_vfork_aarch64.inc.S | 2 +-
21 compiler-rt/lib/tsan/rtl/tsan_rtl_aarch64.S | 2 +-
22 8 files changed, 22 insertions(+), 14 deletions(-)
23
24diff --git a/compiler-rt/lib/builtins/aarch64/lse.S b/compiler-rt/lib/builtins/aarch64/lse.S
25index 1fe18f4a4681..abad047096cc 100644
26--- a/compiler-rt/lib/builtins/aarch64/lse.S
27+++ b/compiler-rt/lib/builtins/aarch64/lse.S
28@@ -264,7 +264,7 @@ END_COMPILERRT_OUTLINE_FUNCTION(NAME(LDNM))
29
30 NO_EXEC_STACK_DIRECTIVE
31
32-// GNU property note for BTI and PAC
33-GNU_PROPERTY_BTI_PAC
34+// GNU property note for BTI, PAC, and GCS
35+GNU_PROPERTY_BTI_PAC_GCS
36
37 #endif // __aarch64__
38diff --git a/compiler-rt/lib/builtins/aarch64/sme-abi.S b/compiler-rt/lib/builtins/aarch64/sme-abi.S
39index 8dbbe061edb9..29d7ad53047d 100644
40--- a/compiler-rt/lib/builtins/aarch64/sme-abi.S
41+++ b/compiler-rt/lib/builtins/aarch64/sme-abi.S
42@@ -371,5 +371,5 @@ END_COMPILERRT_FUNCTION(__arm_sme_restore)
43
44 NO_EXEC_STACK_DIRECTIVE
45
46-// GNU property note for BTI and PAC
47-GNU_PROPERTY_BTI_PAC
48+// GNU property note for BTI, PAC, and GCS
49+GNU_PROPERTY_BTI_PAC_GCS
50diff --git a/compiler-rt/lib/builtins/assembly.h b/compiler-rt/lib/builtins/assembly.h
51index 34c71241524d..a554c10c18ac 100644
52--- a/compiler-rt/lib/builtins/assembly.h
53+++ b/compiler-rt/lib/builtins/assembly.h
54@@ -79,11 +79,12 @@
55 #define FUNC_ALIGN
56 #endif
57
58-// BTI and PAC gnu property note
59+// BTI, PAC, and GCS gnu property note
60 #define NT_GNU_PROPERTY_TYPE_0 5
61 #define GNU_PROPERTY_AARCH64_FEATURE_1_AND 0xc0000000
62 #define GNU_PROPERTY_AARCH64_FEATURE_1_BTI 1
63 #define GNU_PROPERTY_AARCH64_FEATURE_1_PAC 2
64+#define GNU_PROPERTY_AARCH64_FEATURE_1_GCS 4
65
66 #if defined(__ARM_FEATURE_BTI_DEFAULT)
67 #define BTI_FLAG GNU_PROPERTY_AARCH64_FEATURE_1_BTI
68@@ -97,6 +98,12 @@
69 #define PAC_FLAG 0
70 #endif
71
72+#if defined(__ARM_FEATURE_GCS_DEFAULT)
73+#define GCS_FLAG GNU_PROPERTY_AARCH64_FEATURE_1_GCS
74+#else
75+#define GCS_FLAG 0
76+#endif
77+
78 #define GNU_PROPERTY(type, value) \
79 .pushsection .note.gnu.property, "a" SEPARATOR \
80 .p2align 3 SEPARATOR \
81@@ -118,11 +125,12 @@
82 #define BTI_J
83 #endif
84
85-#if (BTI_FLAG | PAC_FLAG) != 0
86-#define GNU_PROPERTY_BTI_PAC \
87- GNU_PROPERTY(GNU_PROPERTY_AARCH64_FEATURE_1_AND, BTI_FLAG | PAC_FLAG)
88+#if (BTI_FLAG | PAC_FLAG | GCS_FLAG) != 0
89+#define GNU_PROPERTY_BTI_PAC_GCS \
90+ GNU_PROPERTY(GNU_PROPERTY_AARCH64_FEATURE_1_AND, \
91+ BTI_FLAG | PAC_FLAG | GCS_FLAG)
92 #else
93-#define GNU_PROPERTY_BTI_PAC
94+#define GNU_PROPERTY_BTI_PAC_GCS
95 #endif
96
97 #if defined(__clang__) || defined(__GCC_HAVE_DWARF2_CFI_ASM)
98diff --git a/compiler-rt/lib/hwasan/hwasan_interceptors_vfork.S b/compiler-rt/lib/hwasan/hwasan_interceptors_vfork.S
99index fd20825e3dac..825f41156509 100644
100--- a/compiler-rt/lib/hwasan/hwasan_interceptors_vfork.S
101+++ b/compiler-rt/lib/hwasan/hwasan_interceptors_vfork.S
102@@ -11,4 +11,4 @@
103
104 NO_EXEC_STACK_DIRECTIVE
105
106-GNU_PROPERTY_BTI_PAC
107+GNU_PROPERTY_BTI_PAC_GCS
108diff --git a/compiler-rt/lib/hwasan/hwasan_setjmp_aarch64.S b/compiler-rt/lib/hwasan/hwasan_setjmp_aarch64.S
109index 0c0abb6de861..b8d98b09ada2 100644
110--- a/compiler-rt/lib/hwasan/hwasan_setjmp_aarch64.S
111+++ b/compiler-rt/lib/hwasan/hwasan_setjmp_aarch64.S
112@@ -99,4 +99,4 @@ ASM_TRAMPOLINE_ALIAS(_setjmp, setjmp)
113 // We do not need executable stack.
114 NO_EXEC_STACK_DIRECTIVE
115
116-GNU_PROPERTY_BTI_PAC
117+GNU_PROPERTY_BTI_PAC_GCS
118diff --git a/compiler-rt/lib/hwasan/hwasan_tag_mismatch_aarch64.S b/compiler-rt/lib/hwasan/hwasan_tag_mismatch_aarch64.S
119index fd060c51cd8e..be82475101c8 100644
120--- a/compiler-rt/lib/hwasan/hwasan_tag_mismatch_aarch64.S
121+++ b/compiler-rt/lib/hwasan/hwasan_tag_mismatch_aarch64.S
122@@ -157,4 +157,4 @@ mismatch:
123 // We do not need executable stack.
124 NO_EXEC_STACK_DIRECTIVE
125
126-GNU_PROPERTY_BTI_PAC
127+GNU_PROPERTY_BTI_PAC_GCS
128diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_vfork_aarch64.inc.S b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_vfork_aarch64.inc.S
129index cdfa6f1d7f53..5066953980af 100644
130--- a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_vfork_aarch64.inc.S
131+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_vfork_aarch64.inc.S
132@@ -43,6 +43,6 @@ ASM_SIZE(vfork)
133 ASM_INTERCEPTOR_TRAMPOLINE(vfork)
134 ASM_TRAMPOLINE_ALIAS(vfork, vfork)
135
136-GNU_PROPERTY_BTI_PAC
137+GNU_PROPERTY_BTI_PAC_GCS
138
139 #endif
140diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl_aarch64.S b/compiler-rt/lib/tsan/rtl/tsan_rtl_aarch64.S
141index 7d920bee4a2d..f1d11a3e7f54 100644
142--- a/compiler-rt/lib/tsan/rtl/tsan_rtl_aarch64.S
143+++ b/compiler-rt/lib/tsan/rtl/tsan_rtl_aarch64.S
144@@ -222,6 +222,6 @@ ASM_SIZE(ASM_SYMBOL_INTERCEPTOR(__sigsetjmp))
145
146 NO_EXEC_STACK_DIRECTIVE
147
148-GNU_PROPERTY_BTI_PAC
149+GNU_PROPERTY_BTI_PAC_GCS
150
151 #endif
diff --git a/meta/recipes-devtools/clang/common.inc b/meta/recipes-devtools/clang/common.inc
index fb96d0679c..cbcc4feded 100644
--- a/meta/recipes-devtools/clang/common.inc
+++ b/meta/recipes-devtools/clang/common.inc
@@ -62,6 +62,7 @@ SRC_URI = "\
62 file://0001-libclc-allow-existing-prepare-builtins-in-standalone.patch \ 62 file://0001-libclc-allow-existing-prepare-builtins-in-standalone.patch \
63 file://no-c-index-test.patch \ 63 file://no-c-index-test.patch \
64 file://0001-llvm-Allow-users-to-set-LLVM_HAVE_OPT_VIEWER_MODULES.patch \ 64 file://0001-llvm-Allow-users-to-set-LLVM_HAVE_OPT_VIEWER_MODULES.patch \
65 file://0001-compiler-rt-AArch64-Add-GCS-property-in-assembly-fil.patch \
65" 66"
66# Fallback to no-PIE if not set 67# Fallback to no-PIE if not set
67GCCPIE ??= "" 68GCCPIE ??= ""