Blame SOURCES/0001-annocheck-warning-about-missing-.note.gnu.property-s.patch

76e0e0
From 6de192ad5ffe9ec04328bfd178050cb8a33e1cbb Mon Sep 17 00:00:00 2001
76e0e0
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
76e0e0
Date: Wed, 15 Dec 2021 12:46:24 +0000
76e0e0
Subject: [PATCH] annocheck warning about missing .note.gnu.property section
76e0e0
MIME-Version: 1.0
76e0e0
Content-Type: text/plain; charset=UTF-8
76e0e0
Content-Transfer-Encoding: 8bit
76e0e0
76e0e0
copy and paste recommendation from:
76e0e0
https://sourceware.org/annobin/annobin.html/Test-cf-protection.html
76e0e0
76e0e0
and adapt like:
76e0e0
https://github.com/openssl/openssl/commit/51994e505dbb1cd0dd76869ec962e2948b77b585
76e0e0
where https://bugs.ruby-lang.org/attachments/8962 is similar
76e0e0
76e0e0
Intel docs have "The ENDBR32 and ENDBR64 (collectively ENDBRANCH) are
76e0e0
two new instructions that are used to mark valid indirect CALL/JMP
76e0e0
target locations in the program."
76e0e0
76e0e0
Change-Id: Ie867c263a888763db4478720ba189c9ec6cc974d
76e0e0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126859
76e0e0
Tested-by: Jenkins
76e0e0
Tested-by: Caolán McNamara <caolanm@redhat.com>
76e0e0
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
76e0e0
(cherry picked from commit af55dc3891f7950d392175004b2090cb0e54828e)
76e0e0
---
76e0e0
 .../source/cpp_uno/gcc3_linux_intel/call.s    | 16 ++++++++++++++++
76e0e0
 .../source/cpp_uno/gcc3_linux_x86-64/call.s   | 19 +++++++++++++++++++
76e0e0
 config_host.mk.in                             |  1 +
76e0e0
 configure.ac                                  | 14 ++++++++++++++
76e0e0
 solenv/gbuild/platform/com_GCC_class.mk       |  1 +
76e0e0
 5 files changed, 51 insertions(+)
76e0e0
76e0e0
diff --git a/bridges/source/cpp_uno/gcc3_linux_intel/call.s b/bridges/source/cpp_uno/gcc3_linux_intel/call.s
76e0e0
index 6be583247733..0a5870defcf3 100644
76e0e0
--- a/bridges/source/cpp_uno/gcc3_linux_intel/call.s
76e0e0
+++ b/bridges/source/cpp_uno/gcc3_linux_intel/call.s
76e0e0
@@ -290,3 +290,19 @@ privateSnippetExecutorClass:
76e0e0
     .align 4
76e0e0
 .LEFDEc:
76e0e0
     .section .note.GNU-stack,"",@progbits
76e0e0
+    .section .note.gnu.property,"a"
76e0e0
+    .p2align 2
76e0e0
+    .long     1f - 0f
76e0e0
+    .long     4f - 1f
76e0e0
+    .long     5
76e0e0
+0:
76e0e0
+    .string     "GNU"
76e0e0
+1:
76e0e0
+    .p2align 2
76e0e0
+    .long     0xc0000002
76e0e0
+    .long     3f - 2f
76e0e0
+2:
76e0e0
+    .long     0x3
76e0e0
+3:
76e0e0
+    .p2align 2
76e0e0
+4:
76e0e0
diff --git a/bridges/source/cpp_uno/gcc3_linux_x86-64/call.s b/bridges/source/cpp_uno/gcc3_linux_x86-64/call.s
76e0e0
index 447ac0cecfdd..2e9346dff8a0 100644
76e0e0
--- a/bridges/source/cpp_uno/gcc3_linux_x86-64/call.s
76e0e0
+++ b/bridges/source/cpp_uno/gcc3_linux_x86-64/call.s
76e0e0
@@ -22,6 +22,9 @@
76e0e0
 	.type	privateSnippetExecutor, @function
76e0e0
 privateSnippetExecutor:
76e0e0
 .LFB3:
76e0e0
+#if defined(END_BRANCH_INS_SUPPORT)
76e0e0
+	endbr64
76e0e0
+#endif
76e0e0
 	pushq	%rbp
76e0e0
 .LCFI0:
76e0e0
 	movq	%rsp, %rbp
76e0e0
@@ -115,3 +118,19 @@ privateSnippetExecutor:
76e0e0
 	.align 8
76e0e0
 .LEFDE1:
76e0e0
 	.section	.note.GNU-stack,"",@progbits
76e0e0
+	.section	.note.gnu.property,"a"
76e0e0
+	.p2align 3
76e0e0
+	.long	 1f - 0f
76e0e0
+	.long	 4f - 1f
76e0e0
+	.long	 5
76e0e0
+0:
76e0e0
+	.string	 "GNU"
76e0e0
+1:
76e0e0
+	.p2align 3
76e0e0
+	.long	 0xc0000002
76e0e0
+	.long	 3f - 2f
76e0e0
+2:
76e0e0
+	.long	 0x3
76e0e0
+3:
76e0e0
+	.p2align 3
76e0e0
+4:
76e0e0
diff --git a/config_host.mk.in b/config_host.mk.in
76e0e0
index d6edba704b21..6ac2a90695e2 100644
76e0e0
--- a/config_host.mk.in
76e0e0
+++ b/config_host.mk.in
76e0e0
@@ -260,6 +260,7 @@ export GTK3_CFLAGS=$(gb_SPACE)@GTK3_CFLAGS@
76e0e0
 export GTK3_LIBS=$(gb_SPACE)@GTK3_LIBS@
76e0e0
 export USING_X11=@USING_X11@
76e0e0
 export HAMCREST_JAR=@HAMCREST_JAR@
76e0e0
+export HAVE_ASM_END_BRANCH_INS_SUPPORT=@HAVE_ASM_END_BRANCH_INS_SUPPORT@
76e0e0
 export HAVE_BROKEN_GCC_WMAYBE_UNINITIALIZED=@HAVE_BROKEN_GCC_WMAYBE_UNINITIALIZED@
76e0e0
 export HAVE_CLANG_DEBUG_INFO_KIND_CONSTRUCTOR=@HAVE_CLANG_DEBUG_INFO_KIND_CONSTRUCTOR@
76e0e0
 export HAVE_LO_CLANG_DLLEXPORTINLINES=@HAVE_LO_CLANG_DLLEXPORTINLINES@
76e0e0
diff --git a/configure.ac b/configure.ac
76e0e0
index bd28bc6eb38e..ef03408e8e98 100644
76e0e0
--- a/configure.ac
76e0e0
+++ b/configure.ac
76e0e0
@@ -7730,6 +7730,20 @@ _ACEOF
76e0e0
 
76e0e0
     CPPFLAGS="$save_CPPFLAGS"
76e0e0
 
76e0e0
+    AC_MSG_CHECKING([if CET endbranch is recognized])
76e0e0
+cat > endbr.s <<_ACEOF
76e0e0
+endbr32
76e0e0
+_ACEOF
76e0e0
+    HAVE_ASM_END_BRANCH_INS_SUPPORT=
76e0e0
+    if $CXX -c endbr.s -o endbr.o >/dev/null 2>&5; then
76e0e0
+        AC_MSG_RESULT([yes])
76e0e0
+        HAVE_ASM_END_BRANCH_INS_SUPPORT=TRUE
76e0e0
+    else
76e0e0
+        AC_MSG_RESULT([no])
76e0e0
+    fi
76e0e0
+    rm -f endbr.s endbr.o
76e0e0
+    AC_SUBST(HAVE_ASM_END_BRANCH_INS_SUPPORT)
76e0e0
+
76e0e0
     AC_LANG_POP([C++])
76e0e0
 fi
76e0e0
 
76e0e0
diff --git a/solenv/gbuild/platform/com_GCC_class.mk b/solenv/gbuild/platform/com_GCC_class.mk
76e0e0
index c29e2a979fd9..e2056abf9682 100644
76e0e0
--- a/solenv/gbuild/platform/com_GCC_class.mk
76e0e0
+++ b/solenv/gbuild/platform/com_GCC_class.mk
76e0e0
@@ -44,6 +44,7 @@ $(call gb_Helper_abbreviate_dirs,\
76e0e0
 		-x assembler-with-cpp \
76e0e0
 		$(gb_LTOFLAGS) \
76e0e0
 		$(gb_AFLAGS) \
76e0e0
+		$(if $(HAVE_ASM_END_BRANCH_INS_SUPPORT),-DEND_BRANCH_INS_SUPPORT) \
76e0e0
 		-c $(3) \
76e0e0
 		-o $(1)) \
76e0e0
 		$(INCLUDE) && \
76e0e0
-- 
76e0e0
2.33.1
76e0e0