[PATCH 3/3] perf x86: Add .note.gnu.property to assembly linked into perf
From: Trevor Allison
Date: Wed Jul 08 2026 - 00:59:17 EST
Assembly sources do not get .note.gnu.property from the compiler.
Add the section to the x86 files that are linked into perf, using the
same approach as the existing .note.GNU-stack notes.
Signed-off-by: Trevor Allison <tallison@xxxxxxxxxx>
---
tools/perf/arch/x86/tests/regs_load.S | 24 ++++++++++++++++++++++++
tools/perf/bench/mem-memcpy-x86-64-asm.S | 24 ++++++++++++++++++++++++
tools/perf/bench/mem-memset-x86-64-asm.S | 24 ++++++++++++++++++++++++
3 files changed, 72 insertions(+)
diff --git a/tools/perf/arch/x86/tests/regs_load.S b/tools/perf/arch/x86/tests/regs_load.S
index 80f14f52e3f6..1947f95cceda 100644
--- a/tools/perf/arch/x86/tests/regs_load.S
+++ b/tools/perf/arch/x86/tests/regs_load.S
@@ -97,3 +97,27 @@ SYM_FUNC_END(perf_regs_load)
* the ELF stack should not be restricted at all and set it RWX.
*/
.section .note.GNU-stack,"",@progbits
+
+/*
+ * We need to provide .note.gnu.property section with IBT and SHSTK,
+ * saying that this object supports the same CET properties as C code
+ * built with -fcf-protection. Otherwise static linking drops CET from
+ * the final perf binary when other objects are CET-enabled.
+ */
+ .pushsection .note.gnu.property, "a"
+ .p2align 3
+ .long 1f - 0f
+ .long 4f - 1f
+ .long 5
+0:
+ .asciz "GNU"
+1:
+ .p2align 3
+ .long 0xc0000002
+ .long 3f - 2f
+2:
+ .long 3
+3:
+ .p2align 3
+4:
+ .popsection
diff --git a/tools/perf/bench/mem-memcpy-x86-64-asm.S b/tools/perf/bench/mem-memcpy-x86-64-asm.S
index 1b9fef7efcdc..e7b84aa43ab4 100644
--- a/tools/perf/bench/mem-memcpy-x86-64-asm.S
+++ b/tools/perf/bench/mem-memcpy-x86-64-asm.S
@@ -18,3 +18,27 @@
* the ELF stack should not be restricted at all and set it RWX.
*/
.section .note.GNU-stack,"",@progbits
+
+/*
+ * We need to provide .note.gnu.property section with IBT and SHSTK,
+ * saying that this object supports the same CET properties as C code
+ * built with -fcf-protection. Otherwise static linking drops CET from
+ * the final perf binary when other objects are CET-enabled.
+ */
+ .pushsection .note.gnu.property, "a"
+ .p2align 3
+ .long 1f - 0f
+ .long 4f - 1f
+ .long 5
+0:
+ .asciz "GNU"
+1:
+ .p2align 3
+ .long 0xc0000002
+ .long 3f - 2f
+2:
+ .long 3
+3:
+ .p2align 3
+4:
+ .popsection
diff --git a/tools/perf/bench/mem-memset-x86-64-asm.S b/tools/perf/bench/mem-memset-x86-64-asm.S
index abd26c95f1aa..f8002da91c3c 100644
--- a/tools/perf/bench/mem-memset-x86-64-asm.S
+++ b/tools/perf/bench/mem-memset-x86-64-asm.S
@@ -13,3 +13,27 @@
* the ELF stack should not be restricted at all and set it RWX.
*/
.section .note.GNU-stack,"",@progbits
+
+/*
+ * We need to provide .note.gnu.property section with IBT and SHSTK,
+ * saying that this object supports the same CET properties as C code
+ * built with -fcf-protection. Otherwise static linking drops CET from
+ * the final perf binary when other objects are CET-enabled.
+ */
+ .pushsection .note.gnu.property, "a"
+ .p2align 3
+ .long 1f - 0f
+ .long 4f - 1f
+ .long 5
+0:
+ .asciz "GNU"
+1:
+ .p2align 3
+ .long 0xc0000002
+ .long 3f - 2f
+2:
+ .long 3
+3:
+ .p2align 3
+4:
+ .popsection
--
2.50.1 (Apple Git-155)