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

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