bridges/Library_cpp_uno.mk | 7 ++++++- config_host.mk.in | 2 +- configure.ac | 23 +++++++++++------------ solenv/gbuild/platform/com_GCC_defs.mk | 6 ++---- 4 files changed, 20 insertions(+), 18 deletions(-)
New commits: commit 91f658c61fef351cebabbbc16faeed46719c1a09 Author: Stephan Bergmann <sberg...@redhat.com> AuthorDate: Fri Oct 11 23:50:19 2019 +0200 Commit: Stephan Bergmann <sberg...@redhat.com> CommitDate: Sat Oct 12 08:10:25 2019 +0200 aarch64 callVirtualFunction needs to be compiled w/o -fstack-clash-protection At least when doing an aarch64 Flatpak build against org.freedesktop.Sdk//19.08, which uses GCC 9.2.0 and passes in `CXXFLAGS=-O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -fasynchronous-unwind-tables -fstack-clash-protection`, callVirtualMethod (in bridges/source/cpp_uno/gcc3_linux_aarch64/callvirtualfunction.cxx) would decrement the stack pointer another 16 bytes after the stackargs = alloca(...); and before the asm block, so in the called virtual function, arguments read from the stack would read garbage (and CustomTarget_testtools/uno_test would fail with SIGSEGV at > #0 0x0000ffffb733eb48 in rtl::OUString::operator= (this=0xaaaaf9c1ac30, str=...) at /run/build/libreoffice/include/rtl/ustring.hxx:453 > #1 0x0000ffffb733a7bc in bridge_object::assign (rData=..., bBool=true, cChar=64 u'@', nByte=17 '\021', nShort=4660, nUShort=65244, nLong=305419896, nULong=4275878552, nHyper=0, nUHyper=187651311381888, fFloat=17.0814991, fDouble=3.1415926358999999, eEnum=-1698898192, rStr=..., xTest=..., rAny=...) at /run/build/libreoffice/testtools/source/bridgetest/cppobj.cxx:99 > #2 0x0000ffffb733a87c in bridge_object::assign (rData=..., bBool=true, cChar=64 u'@', nByte=17 '\021', nShort=4660, nUShort=65244, nLong=305419896, nULong=4275878552, nHyper=0, nUHyper=187651311381888, fFloat=17.0814991, fDouble=3.1415926358999999, eEnum=-1698898192, rStr=..., xTest=..., rAny=..., rSequence=...) at /run/build/libreoffice/testtools/source/bridgetest/cppobj.cxx:115 > #3 0x0000ffffb733ade4 in bridge_object::Test_Impl::setValues (this=0xaaaaf9c1abb0, bBool=1 '\001', cChar=64 u'@', nByte=17 '\021', nShort=4660, nUShort=65244, nLong=305419896, nULong=4275878552, nHyper=0, nUHyper=187651311381888, fFloat=17.0814991, fDouble=3.1415926358999999, eEnum=-1698898192, rStr=..., xTest=..., rAny=..., rSequence=..., rStruct=...) at /run/build/libreoffice/testtools/source/bridgetest/cppobj.cxx:548 > #4 0x0000ffffb740bff4 in callVirtualFunction (function=281473755360772, gpr=0xffffd1ab1f28, fpr=0xffffd1ab1f68, stack=0xffffd1ab1d40, sp=8, ret=0xffffd1ab22c0) at /run/build/libreoffice/bridges/source/cpp_uno/gcc3_linux_aarch64/callvirtualfunction.cxx:63 > #5 0x0000ffffb740ca70 in (anonymous namespace)::call (proxy=0xaaaaf9c291c0, slot=..., returnType=0xaaaaf9c00770, count=17, parameters=0xaaaaf9c3a210, returnValue=0xffffd1ab22c0, arguments=0xffffd1ab2230, exception=0xffffd1ab2370) at /run/build/libreoffice/bridges/source/cpp_uno/gcc3_linux_aarch64/uno2cpp.cxx:178 > #6 0x0000ffffb740d4c4 in bridges::cpp_uno::shared::unoInterfaceProxyDispatch (pUnoI=0xaaaaf9c291c0, pMemberDescr=0xaaaaf9c55950, pReturn=0xffffd1ab22c0, pArgs=0xffffd1ab2230, ppException=0xffffd1ab2370) at /run/build/libreoffice/bridges/source/cpp_uno/gcc3_linux_aarch64/uno2cpp.cxx:361 > #7 0x0000ffffb740720c in (anonymous namespace)::call (proxy=0xaaaaf9c549c0, description=..., returnType=0xaaaaf9c00770, count=17, parameters=0xaaaaf9c3a210, gpr=0xffffd1ab2510, fpr=0xffffd1ab2550, stack=0xffffd1ab2590, indirectRet=0xffffb7d24790) at /run/build/libreoffice/bridges/source/cpp_uno/gcc3_linux_aarch64/cpp2uno.cxx:120 > #8 0x0000ffffb74079a0 in (anonymous namespace)::vtableCall (functionIndex=40, vtableOffset=0, gpr=0xffffd1ab2510, fpr=0xffffd1ab2550, stack=0xffffd1ab2590, indirectRet=0xffffb7d24790) at /run/build/libreoffice/bridges/source/cpp_uno/gcc3_linux_aarch64/cpp2uno.cxx:291 > #9 0x0000ffffb7407b00 in (anonymous namespace)::vtableSlotCall (gpr0=187651311618536, gpr1=1, gpr2=64, gpr3=17, gpr4=4660, gpr5=65244, gpr6=305419896, gpr7=4275878552, fpr0=5.4321266044931319e-315, fpr1=3.1415926358999999, fpr2=0, fpr3=4.0039072046065485, fpr4=0, fpr5=4.003911019303815, fpr6=8.9589789687541617e+102, fpr7=-4.4588500238274385e-308) at /run/build/libreoffice/bridges/source/cpp_uno/gcc3_linux_aarch64/cpp2uno.cxx:348 > #10 0x0000ffffb739e60c in bridge_test::performTest (xContext=..., xLBT=..., noCurrentContext=false) at /run/build/libreoffice/testtools/source/bridgetest/bridgetest.cxx:378 > #11 0x0000ffffb73a3d58 in bridge_test::TestBridgeImpl::run (this=0xaaaaf9c18550, rArgs=...) at /run/build/libreoffice/testtools/source/bridgetest/bridgetest.cxx:1162 > #12 0x0000aaaad292a3ec in sal_main () at /run/build/libreoffice/cpputools/source/unoexe/unoexe.cxx:509 > #13 0x0000aaaad29297a0 in main (argc=8, argv=0xffffd1ab31b8) at /run/build/libreoffice/cpputools/source/unoexe/unoexe.cxx:349 .) By experiment, I found the problematic thing to be -fstack-clash-protection, which can apparently be cancelled with a subsequent -fno-stack-clash-protection at least on that GCC 9.2.0. (And -f[no-]stack-clash-protection appears to only be available since GCC 8, and not at all for Clang, so check for it with HAVE_GCC_STACK_CLASH_PROTECTION.) Change-Id: If667fdf704b1ba20a04593b38d2d1f079280df41 Reviewed-on: https://gerrit.libreoffice.org/80701 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sberg...@redhat.com> diff --git a/bridges/Library_cpp_uno.mk b/bridges/Library_cpp_uno.mk index f9e573bd7ff2..277c54cf79dc 100644 --- a/bridges/Library_cpp_uno.mk +++ b/bridges/Library_cpp_uno.mk @@ -30,7 +30,12 @@ else ifeq ($(CPUNAME),AARCH64) ifneq ($(filter ANDROID DRAGONFLY FREEBSD LINUX NETBSD OPENBSD,$(OS)),) bridges_SELECTED_BRIDGE := gcc3_linux_aarch64 -bridge_exception_objects := abi callvirtualfunction uno2cpp +bridge_exception_objects := abi uno2cpp + +$(eval $(call gb_Library_add_exception_objects,$(gb_CPPU_ENV)_uno, \ + bridges/source/cpp_uno/$(bridges_SELECTED_BRIDGE)/callvirtualfunction, \ + $(if $(HAVE_GCC_STACK_CLASH_PROTECTION),-fno-stack-clash-protection) \ +)) $(eval $(call gb_Library_add_exception_objects,$(gb_CPPU_ENV)_uno, \ bridges/source/cpp_uno/$(bridges_SELECTED_BRIDGE)/cpp2uno, \ diff --git a/config_host.mk.in b/config_host.mk.in index cbfa19f0e7b4..e621a4e03845 100644 --- a/config_host.mk.in +++ b/config_host.mk.in @@ -250,6 +250,7 @@ export HAVE_GCC_FNO_ENFORCE_EH_SPECS=@HAVE_GCC_FNO_ENFORCE_EH_SPECS@ export HAVE_GCC_FNO_SIZED_DEALLOCATION=@HAVE_GCC_FNO_SIZED_DEALLOCATION@ export HAVE_GCC_GGDB2=@HAVE_GCC_GGDB2@ export HAVE_GCC_SPLIT_DWARF=@HAVE_GCC_SPLIT_DWARF@ +export HAVE_GCC_STACK_CLASH_PROTECTION=@HAVE_GCC_STACK_CLASH_PROTECTION@ export HAVE_GNUMAKE_FILE_FUNC=@HAVE_GNUMAKE_FILE_FUNC@ export HAVE_LD_BSYMBOLIC_FUNCTIONS=@HAVE_LD_BSYMBOLIC_FUNCTIONS@ export HAVE_LD_HASH_STYLE=@HAVE_LD_HASH_STYLE@ diff --git a/configure.ac b/configure.ac index 809ed94733a2..717dafe71648 100644 --- a/configure.ac +++ b/configure.ac @@ -6155,7 +6155,17 @@ AC_CONFIG_HEADERS([config_host/config_probes.h]) dnl =================================================================== dnl GCC features dnl =================================================================== +HAVE_GCC_STACK_CLASH_PROTECTION= if test "$GCC" = "yes" -o "$COM_IS_CLANG" = TRUE; then + AC_MSG_CHECKING([whether $CC_BASE supports -fstack-clash-protection]) + save_CFLAGS=$CFLAGS + CFLAGS="$CFLAGS -fstack-clash-protection" + AC_LINK_IFELSE( + [AC_LANG_PROGRAM(, [[return 0;]])], + [AC_MSG_RESULT([yes]); HAVE_GCC_STACK_CLASH_PROTECTION=TRUE], + [AC_MSG_RESULT([no])]) + CFLAGS=$save_CFLAGS + AC_MSG_CHECKING([whether $CC_BASE supports -mno-avx]) save_CFLAGS=$CFLAGS CFLAGS="$CFLAGS -Werror -mno-avx" @@ -6340,6 +6350,7 @@ fi AC_SUBST(HAVE_GCC_AVX) AC_SUBST(HAVE_GCC_BUILTIN_ATOMIC) AC_SUBST(HAVE_GCC_BUILTIN_FFS) +AC_SUBST(HAVE_GCC_STACK_CLASH_PROTECTION) dnl =================================================================== dnl Identify the C++ library commit 9db11a8ab648f4d04e59e6bb94cd640f64835447 Author: Stephan Bergmann <sberg...@redhat.com> AuthorDate: Fri Oct 11 23:16:59 2019 +0200 Commit: Stephan Bergmann <sberg...@redhat.com> CommitDate: Sat Oct 12 08:09:51 2019 +0200 -fstack-protector-strong is long since available ...on our baselines, since <https://gcc.gnu.org/git/ ?p=gcc.git;a=commitdiff;h=b156ec373ccf27f4fcce7972de5e043d35acea43> (GCC 4.9?) and <https://github.com/llvm/llvm-project/commit/ e0fc1a80cba8b91e3943f3287e7dcf68c6bb9b7f> "[stackprotector] Add command line option -fstack-protector-strong" (Clang 3.5?) Change-Id: I48237b2304a1ee273cc66f0bb458e890a5a2f21a Reviewed-on: https://gerrit.libreoffice.org/80700 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sberg...@redhat.com> diff --git a/config_host.mk.in b/config_host.mk.in index 91ced61d3d94..cbfa19f0e7b4 100644 --- a/config_host.mk.in +++ b/config_host.mk.in @@ -244,7 +244,6 @@ export USING_X11=@USING_X11@ export HAMCREST_JAR=@HAMCREST_JAR@ export HAVE_BROKEN_GCC_WMAYBE_UNINITIALIZED=@HAVE_BROKEN_GCC_WMAYBE_UNINITIALIZED@ export HAVE_GCC_AVX=@HAVE_GCC_AVX@ -export HAVE_GCC_STACK_PROTECTOR_STRONG=@HAVE_GCC_STACK_PROTECTOR_STRONG@ export HAVE_GCC_BUILTIN_ATOMIC=@HAVE_GCC_BUILTIN_ATOMIC@ export HAVE_GCC_BUILTIN_FFS=@HAVE_GCC_BUILTIN_FFS@ export HAVE_GCC_FNO_ENFORCE_EH_SPECS=@HAVE_GCC_FNO_ENFORCE_EH_SPECS@ diff --git a/configure.ac b/configure.ac index 0c8388fbc9a5..809ed94733a2 100644 --- a/configure.ac +++ b/configure.ac @@ -6167,17 +6167,6 @@ if test "$GCC" = "yes" -o "$COM_IS_CLANG" = TRUE; then AC_MSG_RESULT([no]) fi - AC_MSG_CHECKING([whether $CC_BASE supports -fstack-protector-strong]) - save_CFLAGS=$CFLAGS - CFLAGS="$CFLAGS -O0 -Werror -fstack-protector-strong" - AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ char a[8]; a[7] = 0; ]])],[ HAVE_GCC_STACK_PROTECTOR_STRONG=TRUE ],[]) - CFLAGS=$save_CFLAGS - if test "$HAVE_GCC_STACK_PROTECTOR_STRONG" = "TRUE"; then - AC_MSG_RESULT([yes]) - else - AC_MSG_RESULT([no]) - fi - AC_MSG_CHECKING([whether $CC_BASE supports atomic functions]) AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ int v = 0; @@ -6349,7 +6338,6 @@ AC_LANG_POP([C++]) fi AC_SUBST(HAVE_GCC_AVX) -AC_SUBST(HAVE_GCC_STACK_PROTECTOR_STRONG) AC_SUBST(HAVE_GCC_BUILTIN_ATOMIC) AC_SUBST(HAVE_GCC_BUILTIN_FFS) diff --git a/solenv/gbuild/platform/com_GCC_defs.mk b/solenv/gbuild/platform/com_GCC_defs.mk index 2c3d5f1a98f3..712a61df544f 100644 --- a/solenv/gbuild/platform/com_GCC_defs.mk +++ b/solenv/gbuild/platform/com_GCC_defs.mk @@ -67,6 +67,7 @@ gb_CFLAGS_COMMON := \ -fmessage-length=0 \ -fno-common \ -pipe \ + -fstack-protector-strong \ gb_CXXFLAGS_COMMON := \ -Wall \ @@ -81,6 +82,7 @@ gb_CXXFLAGS_COMMON := \ -fmessage-length=0 \ -fno-common \ -pipe \ + -fstack-protector-strong \ gb_CXXFLAGS_DISABLE_WARNINGS = -w @@ -134,11 +136,7 @@ endif gb_VISIBILITY_FLAGS_CXX := -fvisibility-inlines-hidden gb_CXXFLAGS_COMMON += $(gb_VISIBILITY_FLAGS_CXX) -ifeq ($(HAVE_GCC_STACK_PROTECTOR_STRONG),TRUE) -gb_CFLAGS_COMMON += -fstack-protector-strong -gb_CXXFLAGS_COMMON += -fstack-protector-strong gb_LinkTarget_LDFLAGS += -fstack-protector-strong -endif ifneq ($(ENABLE_PCH),) ifeq ($(COM_IS_CLANG),TRUE) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits