[llvm] [Support] Adjust .note.GNU-stack guard in Support/BLAKE3/blake3_*_x86… (PR #76229)

Rainer Orth via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 12 06:19:22 PST 2024


https://github.com/rorth updated https://github.com/llvm/llvm-project/pull/76229

>From 70b35e17bfdc5a5fced2a06fc97b982a7a850cdf Mon Sep 17 00:00:00 2001
From: Rainer Orth <ro at gcc.gnu.org>
Date: Fri, 22 Dec 2023 10:52:13 +0100
Subject: [PATCH 1/2] [Support] Adjust .note.GNU-stack guard in
 Support/BLAKE3/blake3_*_x86-64_unix.S

When using GNU ld 2.41 on FreeBSD 14.0/amd64, there are linker warnings like
```
/vol/gcc/bin/gld-2.41: warning: blake3_avx512_x86-64_unix.S.o: missing .note.GNU-stack section implies executable stack
/vol/gcc/bin/gld-2.41: NOTE: This behaviour is deprecated and will be removed in a future version of the linker
```
This can be fixed by adjusting the guard of the `.note.GNU-stack` sections
in `blake3_*_x86-64_unix.S` to match other instances.

Tested on `amd64-pc-freebsd14.0`.
---
 llvm/lib/Support/BLAKE3/blake3_avx2_x86-64_unix.S   | 2 +-
 llvm/lib/Support/BLAKE3/blake3_avx512_x86-64_unix.S | 2 +-
 llvm/lib/Support/BLAKE3/blake3_sse2_x86-64_unix.S   | 2 +-
 llvm/lib/Support/BLAKE3/blake3_sse41_x86-64_unix.S  | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/llvm/lib/Support/BLAKE3/blake3_avx2_x86-64_unix.S b/llvm/lib/Support/BLAKE3/blake3_avx2_x86-64_unix.S
index 69fc0936d73c56..a1210f98d5fa99 100644
--- a/llvm/lib/Support/BLAKE3/blake3_avx2_x86-64_unix.S
+++ b/llvm/lib/Support/BLAKE3/blake3_avx2_x86-64_unix.S
@@ -2,7 +2,7 @@
 
 #include "llvm_blake3_prefix.h"
 
-#if defined(__ELF__) && defined(__linux__)
+#if defined(__ELF__) && (defined(__linux__) || defined(__FreeBSD__) || defined(__Fuchsia__))
 .section .note.GNU-stack,"",%progbits
 #endif
 
diff --git a/llvm/lib/Support/BLAKE3/blake3_avx512_x86-64_unix.S b/llvm/lib/Support/BLAKE3/blake3_avx512_x86-64_unix.S
index f04a135dd1bc48..877359de93c085 100644
--- a/llvm/lib/Support/BLAKE3/blake3_avx512_x86-64_unix.S
+++ b/llvm/lib/Support/BLAKE3/blake3_avx512_x86-64_unix.S
@@ -2,7 +2,7 @@
 
 #include "llvm_blake3_prefix.h"
 
-#if defined(__ELF__) && defined(__linux__)
+#if defined(__ELF__) && (defined(__linux__) || defined(__FreeBSD__) || defined(__Fuchsia__))
 .section .note.GNU-stack,"",%progbits
 #endif
 
diff --git a/llvm/lib/Support/BLAKE3/blake3_sse2_x86-64_unix.S b/llvm/lib/Support/BLAKE3/blake3_sse2_x86-64_unix.S
index 9a4f5eb7318bf9..bd8cb8e888e6fe 100644
--- a/llvm/lib/Support/BLAKE3/blake3_sse2_x86-64_unix.S
+++ b/llvm/lib/Support/BLAKE3/blake3_sse2_x86-64_unix.S
@@ -2,7 +2,7 @@
 
 #include "llvm_blake3_prefix.h"
 
-#if defined(__ELF__) && defined(__linux__)
+#if defined(__ELF__) && (defined(__linux__) || defined(__FreeBSD__) || defined(__Fuchsia__))
 .section .note.GNU-stack,"",%progbits
 #endif
 
diff --git a/llvm/lib/Support/BLAKE3/blake3_sse41_x86-64_unix.S b/llvm/lib/Support/BLAKE3/blake3_sse41_x86-64_unix.S
index 1be4ed744426b0..b273047630883a 100644
--- a/llvm/lib/Support/BLAKE3/blake3_sse41_x86-64_unix.S
+++ b/llvm/lib/Support/BLAKE3/blake3_sse41_x86-64_unix.S
@@ -2,7 +2,7 @@
 
 #include "llvm_blake3_prefix.h"
 
-#if defined(__ELF__) && defined(__linux__)
+#if defined(__ELF__) && (defined(__linux__) || defined(__FreeBSD__) || defined(__Fuchsia__))
 .section .note.GNU-stack,"",%progbits
 #endif
 

>From f1c44b2f574f6c0953d8322b36ee97ffdbae55d4 Mon Sep 17 00:00:00 2001
From: Rainer Orth <ro at gcc.gnu.org>
Date: Fri, 12 Jan 2024 15:17:50 +0100
Subject: [PATCH 2/2] Change guards to only exclude Solaris, matching
 MCAsmInfoELF::getNonexecutableStackSection.

---
 llvm/lib/Support/BLAKE3/blake3_avx2_x86-64_unix.S   | 2 +-
 llvm/lib/Support/BLAKE3/blake3_avx512_x86-64_unix.S | 2 +-
 llvm/lib/Support/BLAKE3/blake3_sse2_x86-64_unix.S   | 2 +-
 llvm/lib/Support/BLAKE3/blake3_sse41_x86-64_unix.S  | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/llvm/lib/Support/BLAKE3/blake3_avx2_x86-64_unix.S b/llvm/lib/Support/BLAKE3/blake3_avx2_x86-64_unix.S
index a1210f98d5fa99..e98893c7ef8b8f 100644
--- a/llvm/lib/Support/BLAKE3/blake3_avx2_x86-64_unix.S
+++ b/llvm/lib/Support/BLAKE3/blake3_avx2_x86-64_unix.S
@@ -2,7 +2,7 @@
 
 #include "llvm_blake3_prefix.h"
 
-#if defined(__ELF__) && (defined(__linux__) || defined(__FreeBSD__) || defined(__Fuchsia__))
+#if defined(__ELF__) && !(defined(__sun__) && defined(__svr4__))
 .section .note.GNU-stack,"",%progbits
 #endif
 
diff --git a/llvm/lib/Support/BLAKE3/blake3_avx512_x86-64_unix.S b/llvm/lib/Support/BLAKE3/blake3_avx512_x86-64_unix.S
index 877359de93c085..224605147c3d7d 100644
--- a/llvm/lib/Support/BLAKE3/blake3_avx512_x86-64_unix.S
+++ b/llvm/lib/Support/BLAKE3/blake3_avx512_x86-64_unix.S
@@ -2,7 +2,7 @@
 
 #include "llvm_blake3_prefix.h"
 
-#if defined(__ELF__) && (defined(__linux__) || defined(__FreeBSD__) || defined(__Fuchsia__))
+#if defined(__ELF__) && !(defined(__sun__) && defined(__svr4__))
 .section .note.GNU-stack,"",%progbits
 #endif
 
diff --git a/llvm/lib/Support/BLAKE3/blake3_sse2_x86-64_unix.S b/llvm/lib/Support/BLAKE3/blake3_sse2_x86-64_unix.S
index bd8cb8e888e6fe..d69a1706fefe77 100644
--- a/llvm/lib/Support/BLAKE3/blake3_sse2_x86-64_unix.S
+++ b/llvm/lib/Support/BLAKE3/blake3_sse2_x86-64_unix.S
@@ -2,7 +2,7 @@
 
 #include "llvm_blake3_prefix.h"
 
-#if defined(__ELF__) && (defined(__linux__) || defined(__FreeBSD__) || defined(__Fuchsia__))
+#if defined(__ELF__) && !(defined(__sun__) && defined(__svr4__))
 .section .note.GNU-stack,"",%progbits
 #endif
 
diff --git a/llvm/lib/Support/BLAKE3/blake3_sse41_x86-64_unix.S b/llvm/lib/Support/BLAKE3/blake3_sse41_x86-64_unix.S
index b273047630883a..c5b103af61c4fd 100644
--- a/llvm/lib/Support/BLAKE3/blake3_sse41_x86-64_unix.S
+++ b/llvm/lib/Support/BLAKE3/blake3_sse41_x86-64_unix.S
@@ -2,7 +2,7 @@
 
 #include "llvm_blake3_prefix.h"
 
-#if defined(__ELF__) && (defined(__linux__) || defined(__FreeBSD__) || defined(__Fuchsia__))
+#if defined(__ELF__) && !(defined(__sun__) && defined(__svr4__))
 .section .note.GNU-stack,"",%progbits
 #endif
 



More information about the llvm-commits mailing list