Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 24, 2024

Conversation

rorth
Copy link
Collaborator

@rorth rorth commented Dec 22, 2023

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

…-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`.
@llvmbot
Copy link
Member

llvmbot commented Dec 22, 2023

@llvm/pr-subscribers-llvm-support

Author: Rainer Orth (rorth)

Changes

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


Full diff: https://github.com/llvm/llvm-project/pull/76229.diff

4 Files Affected:

  • (modified) llvm/lib/Support/BLAKE3/blake3_avx2_x86-64_unix.S (+1-1)
  • (modified) llvm/lib/Support/BLAKE3/blake3_avx512_x86-64_unix.S (+1-1)
  • (modified) llvm/lib/Support/BLAKE3/blake3_sse2_x86-64_unix.S (+1-1)
  • (modified) llvm/lib/Support/BLAKE3/blake3_sse41_x86-64_unix.S (+1-1)
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
 

@@ -2,7 +2,7 @@

#include "llvm_blake3_prefix.h"

#if defined(__ELF__) && defined(__linux__)
#if defined(__ELF__) && (defined(__linux__) || defined(__FreeBSD__) || defined(__Fuchsia__))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be defined for all ELF OSes except possibly Solaris which may use an alternative section syntax.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Solaris issue is not the different section syntax (which would only apply on SPARC if clang supported /usr/bin/as as external assembler, which it doesn't), but the fact that Solaris doesn't care about .note.GNU-stack at all (cf. llvm/lib/MC/MCAsmInfoELF.cpp:MCAsmInfoELF::getNonexecutableStackSection.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've now changed the guards to match MCAsmInfoELF::getNonexecutableStackSection. While we are consistent here now, the guards in BLAKE3 differ from every other instance in the LLVM codebase.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I forgot: tested on amd64-pc-freebsd14.0 and amd64-pc-solaris2.11.

MCAsmInfoELF::getNonexecutableStackSection.
@rorth
Copy link
Collaborator Author

rorth commented Jan 23, 2024

Ping? It's been two weeks.

@MaskRay
Copy link
Member

MaskRay commented Jan 24, 2024

Did you propose this to https://github.com/BLAKE3-team/BLAKE3/tree/master/c ? The next upgrader will likely notice this local change.

@rorth
Copy link
Collaborator Author

rorth commented Jan 24, 2024

Did you propose this to https://github.com/BLAKE3-team/BLAKE3/tree/master/c ? The next upgrader will likely notice this local change.

Not yet: I'd seen that there were many patches local to LLVM that seemed not to have gone upstream. I'll give it a try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants