git: d74f1e0a8d38 - main - editors/openoffice-*: Fix build on powerpc64

From: Don Lewis <truckman_at_FreeBSD.org>
Date: Mon, 04 Nov 2024 12:00:00 UTC
The branch main has been updated by truckman:

URL: https://cgit.FreeBSD.org/ports/commit/?id=d74f1e0a8d38d54eae26f2494ef077eb05c653fb

commit d74f1e0a8d38d54eae26f2494ef077eb05c653fb
Author:     Curtis Hamilton <hamiltcl@verizon.net>
AuthorDate: 2024-11-04 11:50:28 +0000
Commit:     Don Lewis <truckman@FreeBSD.org>
CommitDate: 2024-11-04 11:59:06 +0000

    editors/openoffice-*: Fix build on powerpc64
    
    The upstream bridges code does not yet work on powerpc64.
    
    PR:             251417
---
 .../openoffice-4/files/patch-bridges_prj_build.lst |  12 +
 ...source_cpp__uno_gcc3__freebsd__powerpc64_call.s | 482 +++++++++++++++++++++
 ...e_cpp__uno_gcc3__freebsd__powerpc64_cpp2uno.cxx | 257 +++++++++++
 ...e_cpp__uno_gcc3__freebsd__powerpc64_makefile.mk |  21 +
 ...rce_cpp__uno_gcc3__freebsd__powerpc64_share.hxx |  78 +++-
 ...e_cpp__uno_gcc3__freebsd__powerpc64_uno2cpp.cxx | 381 +++++++++++++++-
 editors/openoffice-4/files/patch-set_soenv.in      |  67 +++
 .../files/patch-solenv_inc_unxfbsdp.mk             |  34 ++
 ...atch-testtools__source__bridgetest__makefile.mk |  12 +
 .../files/patch-bridges_Library__cpp__uno.mk       |  14 +
 ...source_cpp__uno_gcc3__freebsd__powerpc64_call.s | 482 +++++++++++++++++++++
 ...e_cpp__uno_gcc3__freebsd__powerpc64_cpp2uno.cxx | 257 +++++++++++
 ...e_cpp__uno_gcc3__freebsd__powerpc64_makefile.mk |  21 +
 ...rce_cpp__uno_gcc3__freebsd__powerpc64_share.hxx |  78 +++-
 ...e_cpp__uno_gcc3__freebsd__powerpc64_uno2cpp.cxx | 381 +++++++++++++++-
 .../files/patch-solenv_inc_unxfbsdp.mk             |  34 ++
 ...atch-testtools__source__bridgetest__makefile.mk |  12 +
 17 files changed, 2601 insertions(+), 22 deletions(-)

diff --git a/editors/openoffice-4/files/patch-bridges_prj_build.lst b/editors/openoffice-4/files/patch-bridges_prj_build.lst
new file mode 100644
index 000000000000..dc66f3102aa6
--- /dev/null
+++ b/editors/openoffice-4/files/patch-bridges_prj_build.lst
@@ -0,0 +1,12 @@
+--- bridges/prj/build.lst.orig
++++ bridges/prj/build.lst
+@@ -9,6 +9,8 @@
+ br	bridges\source\cpp_uno\gcc3_freebsd_intel	nmake	-	u	br_gcc3fi br_cppuno_shared br_unotypes br_inc NULL
+ br	bridges\source\cpp_uno\gcc3_linux_x86-64	nmake	-	u	br_gcc3lx br_cppuno_shared br_unotypes br_inc NULL
+ br	bridges\source\cpp_uno\gcc3_freebsd_x86-64	nmake	-	u	br_gcc3fx br_cppuno_shared br_unotypes br_inc NULL
++br	bridges\source\cpp_uno\gcc3_freebsd_powerpc	nmake	-	u	br_gcc3fp br_cppuno_shared br_unotypes br_inc NULL
++br	bridges\source\cpp_uno\gcc3_freebsd_powerpc64	nmake	-	u	br_gcc3fp_64 br_cppuno_shared br_unotypes br_inc NULL
+ br	bridges\source\cpp_uno\gcc3_linux_powerpc	nmake	-	u	br_gcc3lp br_cppuno_shared br_unotypes br_inc NULL
+ br	bridges\source\cpp_uno\gcc3_linux_powerpc64	nmake	-	u	br_gcc3lp_64 br_cppuno_shared br_unotypes br_inc NULL
+ br	bridges\source\cpp_uno\gcc3_linux_mips		nmake	-	u	br_gcc3lmips br_cppuno_shared br_unotypes br_inc NULL
+
diff --git a/editors/openoffice-4/files/patch-bridges_source_cpp__uno_gcc3__freebsd__powerpc64_call.s b/editors/openoffice-4/files/patch-bridges_source_cpp__uno_gcc3__freebsd__powerpc64_call.s
new file mode 100644
index 000000000000..f8c5e20e333e
--- /dev/null
+++ b/editors/openoffice-4/files/patch-bridges_source_cpp__uno_gcc3__freebsd__powerpc64_call.s
@@ -0,0 +1,482 @@
+--- /dev/null
++++ bridges/source/cpp_uno/gcc3_freebsd_powerpc64/call.s
+@@ -0,0 +1,478 @@
++	.file	"uno_ppc64_asm.cc"
++	.machine power4
++	.abiversion 2
++	.section	".text"
++	.align 2
++	.globl callVirtualMethod
++	.type	callVirtualMethod, @function
++callVirtualMethod:
++.LFB0:
++	.cfi_startproc
++.LCF0:
++0:	addis 2,12,.TOC.-.LCF0@ha
++	addi 2,2,.TOC.-.LCF0@l
++	.localentry	callVirtualMethod,.-callVirtualMethod
++	mflr 0
++	std 0,16(1)
++	std 31,-8(1)
++	stdu 1,-208(1)
++	.cfi_def_cfa_offset 208
++	.cfi_offset 65, 16
++	.cfi_offset 31, -8
++	mr 31,1
++	.cfi_def_cfa_register 31
++	std 3,136(31)
++	std 5,128(31)
++	std 6,120(31)
++	std 7,112(31)
++	std 9,104(31)
++	mr 9,4
++	stw 9,248(31)
++	mr 9,8
++	stw 9,280(31)
++	mr 9,10
++	stw 9,296(31)
++	ld 9,304(31)
++	std 9,96(31)
++	ld 9,-28688(13)
++	std 9,184(31)
++	li 9,0
++	lwz 9,280(31)
++	cmpwi 0,9,0
++	beq 0,.L2
++	lwz 9,280(31)
++	addi 9,9,1
++	rldicl 9,9,0,32
++	rlwinm 9,9,0,0,30
++	stw 9,280(31)
++.L2:
++#ifdef __LITTLE_ENDIAN__
++	lwz 9,312(31)
++#else
++	lwz 9,316(31)
++#endif
++	cmplwi 0,9,13
++	ble 0,.L3
++	li 9,13
++#ifdef __LITTLE_ENDIAN__
++	stw 9,312(31)
++#else
++	stw 9,316(31)
++#endif
++.L3:
++	lwz 9,296(31)
++	cmplwi 0,9,8
++	ble 0,.L4
++	li 9,8
++	stw 9,296(31)
++.L4:
++	lwz 9,280(31)
++	slwi 9,9,3
++	rldicl 9,9,0,32
++	addi 9,9,15
++	srdi 9,9,4
++	sldi 9,9,4
++	ld 10,0(1)
++	neg 9,9
++	stdux 10,1,9
++	addi 9,1,96
++	addi 9,9,15
++	srdi 9,9,4
++	sldi 9,9,4
++	std 9,160(31)
++	lwz 9,280(31)
++	slwi 9,9,3
++	rldicl 9,9,0,32
++	mr 8,9
++	ld 10,160(31)
++	ld 9,112(31)
++	mr 5,8
++	mr 4,9
++	mr 3,10
++	bl memcpy
++	nop
++	ld 9,136(31)
++	ld 9,0(9)
++	std 9,168(31)
++	lwz 9,248(31)
++	slwi 9,9,3
++	rldicl 9,9,0,32
++	mr 10,9
++	ld 9,168(31)
++	add 9,9,10
++	std 9,168(31)
++	ld 9,168(31)
++	ld 9,0(9)
++	std 9,168(31)
++	ld 9,168(31)
++	std 9,176(31)
++	ld 9,96(31)
++#APP
++ # 123 "uno_ppc64_asm.cc" 1
++	lfd  1,  0(9)
++	lfd  2,  8(9)
++	lfd  3, 16(9)
++	lfd  4, 24(9)
++	lfd  5, 32(9)
++	lfd  6, 40(9)
++	lfd  7, 48(9)
++	lfd  8, 56(9)
++	lfd  9, 64(9)
++	lfd 10, 72(9)
++	lfd 11, 80(9)
++	lfd 12, 88(9)
++	lfd 13, 96(9)
++	
++ # 0 "" 2
++#NO_APP
++	ld 9,104(31)
++	ld 3,0(9)
++	ld 9,104(31)
++	addi 9,9,8
++	ld 4,0(9)
++	ld 9,104(31)
++	addi 9,9,16
++	ld 5,0(9)
++	ld 9,104(31)
++	addi 9,9,24
++	ld 6,0(9)
++	ld 9,104(31)
++	addi 9,9,32
++	ld 7,0(9)
++	ld 9,104(31)
++	addi 9,9,40
++	ld 8,0(9)
++	ld 9,104(31)
++	addi 9,9,48
++	ld 0,0(9)
++	ld 9,104(31)
++	addi 9,9,56
++	ld 9,0(9)
++	ld 11,176(31)
++	mr 10,9
++	mr 9,0
++	std 2,24(1)
++	mr 12,11
++	mtctr 12
++	bctrl
++	ld 2,24(1)
++#APP
++ # 149 "uno_ppc64_asm.cc" 1
++	mr     3,     3
++	mr     4,     4
++	fmr    0,     1
++	
++ # 0 "" 2
++#NO_APP
++	stfd 0,152(31)
++	mr 9,3
++	mr 10,4
++	lfd 0,152(31)
++	ld 7,128(31)
++	ld 6,120(31)
++	fmr 1,0
++	mr 4,10
++	mr 3,9
++	bl MapReturn
++	nop
++	nop
++	ld 9,184(31)
++	ld 10,-28688(13)
++	xor. 9,9,10
++	li 10,0
++	beq 0,.L5
++	bl __stack_chk_fail
++	nop
++.L5:
++	addi 1,31,208
++	.cfi_def_cfa 1, 0
++	ld 0,16(1)
++	mtlr 0
++	ld 31,-8(1)
++	blr
++	.long 0
++	.byte 0,9,0,1,128,1,0,1
++	.cfi_endproc
++.LFE0:
++	.size	callVirtualMethod,.-callVirtualMethod
++	.section	".toc","aw"
++	.align 3
++.LC0:
++	.quad	.L9
++	.section	".text"
++	.align 2
++	.globl privateSnippetExecutor
++	.type	privateSnippetExecutor, @function
++privateSnippetExecutor:
++.LFB1:
++	.cfi_startproc
++.LCF1:
++0:	addis 2,12,.TOC.-.LCF1@ha
++	addi 2,2,.TOC.-.LCF1@l
++	.localentry	privateSnippetExecutor,.-privateSnippetExecutor
++	mflr 0
++	std 0,16(1)
++	std 31,-8(1)
++	stdu 1,-272(1)
++	.cfi_def_cfa_offset 272
++	.cfi_offset 65, 16
++	.cfi_offset 31, -8
++	mr 31,1
++	.cfi_def_cfa_register 31
++	ld 0,-28688(13)
++	std 0,248(31)
++	li 0,0
++	std 3,80(31)
++	std 4,88(31)
++	std 5,96(31)
++	std 6,104(31)
++	std 7,112(31)
++	std 8,120(31)
++	std 9,128(31)
++	mr 9,10
++	std 9,136(31)
++	addi 9,31,144
++#APP
++ # 173 "uno_ppc64_asm.cc" 1
++	stfd 1,   0(9)	
++stfd 2,   8(9)	
++stfd 3,  16(9)	
++stfd 4,  24(9)	
++stfd 5,  32(9)	
++stfd 6,  40(9)	
++stfd 7,  48(9)	
++stfd 8,  56(9)	
++stfd 9,  64(9)	
++stfd 10, 72(9)	
++stfd 11, 80(9)	
++stfd 12, 88(9)	
++stfd 13, 96(9)	
++
++ # 0 "" 2
++#NO_APP
++	std 11,48(31)
++	std 1,56(31)
++	ld 9,48(31)
++	addi 7,31,64
++	addi 8,31,144
++	addi 10,31,80
++	ld 6,56(31)
++	mr 5,8
++	mr 4,10
++	mr 3,9
++	bl cpp_mediate
++	nop
++	mr 9,3
++	stw 9,44(31)
++	lwa 9,44(31)
++	cmplwi 0,9,15
++	bgt 0,.L7
++	sldi 10,9,2
++	addis 8,2,.LC0@toc@ha
++	ld 9,.LC0@toc@l(8)
++	add 9,10,9
++	lwz 10,0(9)
++	ld 9,.LC0@toc@l(8)
++	extsw 10,10
++	add 9,10,9
++	mtctr 9
++	bctr
++	.p2align 2
++	.align 2
++.L9:
++	.long .L19-.L9
++	.long .L13-.L9
++	.long .L15-.L9
++	.long .L15-.L9
++	.long .L14-.L9
++	.long .L13-.L9
++	.long .L12-.L9
++	.long .L8-.L9
++	.long .L7-.L9
++	.long .L7-.L9
++	.long .L11-.L9
++	.long .L10-.L9
++	.long .L7-.L9
++	.long .L7-.L9
++	.long .L7-.L9
++	.long .L8-.L9
++.L15:
++#APP
++ # 209 "uno_ppc64_asm.cc" 1
++	lbz 3,64(31)
++	
++ # 0 "" 2
++#NO_APP
++	b .L17
++.L13:
++#APP
++ # 214 "uno_ppc64_asm.cc" 1
++	lhz 3,64(31)
++	
++ # 0 "" 2
++#NO_APP
++	b .L17
++.L14:
++#APP
++ # 218 "uno_ppc64_asm.cc" 1
++	lha 3,64(31)
++	
++ # 0 "" 2
++#NO_APP
++	b .L17
++.L8:
++#APP
++ # 223 "uno_ppc64_asm.cc" 1
++	lwz 3,64(31)
++	
++ # 0 "" 2
++#NO_APP
++	b .L17
++.L12:
++#APP
++ # 227 "uno_ppc64_asm.cc" 1
++	lwa 3,64(31)
++	
++ # 0 "" 2
++#NO_APP
++	b .L17
++.L11:
++	addi 9,31,64
++#APP
++ # 231 "uno_ppc64_asm.cc" 1
++	lfs 1,0(9)
++	
++ # 0 "" 2
++#NO_APP
++	b .L17
++.L10:
++	addi 9,31,64
++#APP
++ # 235 "uno_ppc64_asm.cc" 1
++	lfd 1,0(9)
++	
++ # 0 "" 2
++#NO_APP
++	b .L17
++.L7:
++#APP
++ # 239 "uno_ppc64_asm.cc" 1
++	ld 3,64(31)
++	
++ # 0 "" 2
++ # 241 "uno_ppc64_asm.cc" 1
++	ld 4,72(31)
++	
++ # 0 "" 2
++#NO_APP
++	b .L17
++.L19:
++	nop
++.L17:
++	nop
++	ld 9,248(31)
++	ld 10,-28688(13)
++	xor. 9,9,10
++	li 10,0
++	beq 0,.L18
++	bl __stack_chk_fail
++	nop
++.L18:
++	addi 1,31,272
++	.cfi_def_cfa 1, 0
++	ld 0,16(1)
++	mtlr 0
++	ld 31,-8(1)
++	blr
++	.long 0
++	.byte 0,9,0,1,128,1,0,1
++	.cfi_endproc
++.LFE1:
++	.size	privateSnippetExecutor,.-privateSnippetExecutor
++	.section	.rodata
++	.align 2
++	.type	_ZL15codeSnippetSize, @object
++	.size	_ZL15codeSnippetSize, 4
++_ZL15codeSnippetSize:
++	.long	32
++	.section	".text"
++	.align 2
++	.globl codeSnippet
++	.type	codeSnippet, @function
++codeSnippet:
++.LFB2:
++	.cfi_startproc
++.LCF2:
++0:	addis 2,12,.TOC.-.LCF2@ha
++	addi 2,2,.TOC.-.LCF2@l
++	.localentry	codeSnippet,.-codeSnippet
++	std 31,-8(1)
++	stdu 1,-96(1)
++	.cfi_def_cfa_offset 96
++	.cfi_offset 31, -8
++	mr 31,1
++	.cfi_def_cfa_register 31
++	std 3,56(31)
++	mr 9,4
++	mr 8,5
++	mr 10,6
++	stw 9,52(31)
++	mr 9,8
++	stw 9,48(31)
++	mr 9,10
++	stb 9,47(31)
++	lwa 9,48(31)
++	sldi 10,9,32
++	lwa 9,52(31)
++	or 9,10,9
++	std 9,64(31)
++	lbz 9,47(31)
++	cmpwi 0,9,0
++	beq 0,.L21
++	ld 9,64(31)
++	oris 9,9,0x8000
++	std 9,64(31)
++.L21:
++	ld 9,56(31)
++	std 9,72(31)
++	ld 9,72(31)
++	lis 10,0xe96c
++	ori 10,10,0x18
++	stw 10,0(9)
++	ld 9,72(31)
++	addi 9,9,4
++	lis 10,0xe98c
++	ori 10,10,0x10
++	stw 10,0(9)
++	ld 9,72(31)
++	addi 9,9,8
++	lis 10,0x7d89
++	ori 10,10,0x3a6
++	stw 10,0(9)
++	ld 9,72(31)
++	addi 9,9,12
++	lis 10,0x4e80
++	ori 10,10,0x420
++	stw 10,0(9)
++	ld 9,72(31)
++	addi 9,9,16
++	addis 10,2,privateSnippetExecutor@toc@ha
++	addi 10,10,privateSnippetExecutor@toc@l
++	std 10,0(9)
++	ld 9,72(31)
++	addi 9,9,24
++	ld 10,64(31)
++	std 10,0(9)
++	ld 9,56(31)
++	addi 9,9,32
++	mr 3,9
++	addi 1,31,96
++	.cfi_def_cfa 1, 0
++	ld 31,-8(1)
++	blr
++	.long 0
++	.byte 0,9,0,0,128,1,0,1
++	.cfi_endproc
++.LFE2:
++	.size	codeSnippet,.-codeSnippet
++	.section	.note.GNU-stack,"",@progbits
+
diff --git a/editors/openoffice-4/files/patch-bridges_source_cpp__uno_gcc3__freebsd__powerpc64_cpp2uno.cxx b/editors/openoffice-4/files/patch-bridges_source_cpp__uno_gcc3__freebsd__powerpc64_cpp2uno.cxx
new file mode 100644
index 000000000000..3efc00f33e34
--- /dev/null
+++ b/editors/openoffice-4/files/patch-bridges_source_cpp__uno_gcc3__freebsd__powerpc64_cpp2uno.cxx
@@ -0,0 +1,257 @@
+--- bridges/source/cpp_uno/gcc3_freebsd_powerpc64/cpp2uno.cxx.orig
++++ bridges/source/cpp_uno/gcc3_freebsd_powerpc64/cpp2uno.cxx
+@@ -28,6 +28,7 @@
+ #include <uno/data.h>
+ #include <typelib/typedescription.hxx>
+ 
++#include <osl/endian.h>
+ #include "bridges/cpp_uno/shared/bridge.hxx"
+ #include "bridges/cpp_uno/shared/cppinterfaceproxy.hxx"
+ #include "bridges/cpp_uno/shared/types.hxx"
+@@ -37,6 +38,11 @@
+ #include <stdio.h>
+ #include <string.h>
+ 
++#ifdef OSL_BIGENDIAN
++#define IS_BIG_ENDIAN 1
++#else
++#define IS_BIG_ENDIAN 0
++#endif
+ 
+ using namespace ::com::sun::star::uno;
+ 
+@@ -144,14 +150,14 @@
+                 case typelib_TypeClass_BYTE:
+                 case typelib_TypeClass_BOOLEAN:
+                     if (ng < ppc64::MAX_GPR_REGS)
+-					{
+-                        pCppArgs[nPos] = pUnoArgs[nPos] = (((char *)gpreg) + (sizeof(void*)-1));
++                    {
++                        pCppArgs[nPos] = pUnoArgs[nPos] = (((char *)gpreg) + 7*IS_BIG_ENDIAN);
+                         ng++;
+                         gpreg++;
+                     }
+                     else
+-					{
+-                        pCppArgs[nPos] = pUnoArgs[nPos] = (((char *)ovrflw) + (sizeof(void*)-1));
++                    {
++                        pCppArgs[nPos] = pUnoArgs[nPos] = (((char *)ovrflw) + 7*IS_BIG_ENDIAN);
+                         bOverFlowUsed = true;
+                     }
+                     if (bOverFlowUsed) ovrflw++;
+@@ -160,14 +166,14 @@
+                 case typelib_TypeClass_SHORT:
+                 case typelib_TypeClass_UNSIGNED_SHORT:
+                     if (ng < ppc64::MAX_GPR_REGS)
+-					{
+-                        pCppArgs[nPos] = pUnoArgs[nPos] = (((char *)gpreg) + (sizeof(void*)-2));
++                    {
++                        pCppArgs[nPos] = pUnoArgs[nPos] = (((char *)gpreg) + 6*IS_BIG_ENDIAN);
+                         ng++;
+                         gpreg++;
+                     }
+                     else
+-					{
+-                        pCppArgs[nPos] = pUnoArgs[nPos] = (((char *)ovrflw) + (sizeof(void*)-2));
++                    {
++                        pCppArgs[nPos] = pUnoArgs[nPos] = (((char *)ovrflw) + 6*IS_BIG_ENDIAN);
+                         bOverFlowUsed = true;
+                     }
+                     if (bOverFlowUsed) ovrflw++;
+@@ -176,14 +182,14 @@
+                 case typelib_TypeClass_LONG:
+                 case typelib_TypeClass_UNSIGNED_LONG:
+                     if (ng < ppc64::MAX_GPR_REGS)
+-					{
+-                        pCppArgs[nPos] = pUnoArgs[nPos] = (((char *)gpreg) + (sizeof(void*)-4));
++                    {
++                        pCppArgs[nPos] = pUnoArgs[nPos] = (((char *)gpreg) + 4*IS_BIG_ENDIAN);
+                         ng++;
+                         gpreg++;
+                     }
+                     else
+-					{
+-                        pCppArgs[nPos] = pUnoArgs[nPos] = (((char *)ovrflw) + (sizeof(void*)-4));
++                    {
++                        pCppArgs[nPos] = pUnoArgs[nPos] = (((char *)ovrflw) + 4*IS_BIG_ENDIAN);
+                         bOverFlowUsed = true;
+                     }
+                     if (bOverFlowUsed) ovrflw++;
+@@ -327,21 +333,25 @@
+ 	}
+ }
+ 
+-
+-//==================================================================================================
+-static typelib_TypeClass cpp_mediate(
+-	sal_uInt64 nOffsetAndIndex,
++#if defined(_CALL_ELF) && _CALL_ELF == 2
++#  define PARAMSAVE 32
++#else
++#  define PARAMSAVE 48
++#endif
++
++extern "C" typelib_TypeClass cpp_mediate(
++    sal_uInt64 nOffsetAndIndex,
+         void ** gpreg, void ** fpreg, long sp,
+-	sal_Int64 * pRegisterReturn /* space for register return */ )
+-{
+-    OSL_ENSURE( sizeof(sal_Int64)==sizeof(void *), "### unexpected!" );
++    sal_Int64 * pRegisterReturn /* space for register return */ )
++{
++    static_assert(sizeof(sal_Int64)==sizeof(void *), "### unexpected!");
+ 
+     sal_Int32 nVtableOffset = (nOffsetAndIndex >> 32);
+     sal_Int32 nFunctionIndex = (nOffsetAndIndex & 0xFFFFFFFF);
+ 
+     long sf = *(long*)sp;
+-    void ** ovrflw = (void**)(sf + 112);
+-	
++    void ** ovrflw = (void**)(sf + PARAMSAVE + 64);
++
+     // gpreg:  [ret *], this, [other gpr params]
+     // fpreg:  [fpr params]
+     // ovrflw: [gpr or fpr params (properly aligned)]
+@@ -501,54 +511,52 @@
+ 	return eRet;
+ }
+ 
+-extern "C" void privateSnippetExecutor( ... )
+-{
+-    volatile long nOffsetAndIndex;
+-
+-    //mr %r3, %r11            # move into arg1 the 64bit value passed from OOo
++extern "C" void privateSnippetExecutor( ... );
++#if 0
++{
++    sal_uInt64 gpreg[ppc64::MAX_GPR_REGS];
++
++    register long r3 asm("r3"); gpreg[0] = r3;
++    register long r4 asm("r4"); gpreg[1] = r4;
++    register long r5 asm("r5"); gpreg[2] = r5;
++    register long r6 asm("r6"); gpreg[3] = r6;
++    register long r7 asm("r7"); gpreg[4] = r7;
++    register long r8 asm("r8"); gpreg[5] = r8;
++    register long r9 asm("r9"); gpreg[6] = r9;
++    register long r10 asm("r10"); gpreg[7] = r10;
++
++    double fpreg[ppc64::MAX_SSE_REGS];
++
+     __asm__ __volatile__ (
+-                "mr     %0,    11\n\t"
+-                : "=r" (nOffsetAndIndex) : );
+-
+-    sal_uInt64 gpreg[ppc64::MAX_GPR_REGS];
+-    double fpreg[ppc64::MAX_SSE_REGS];
+-
+-    __asm__ __volatile__ (
+-        "std 3,   0(%0)\t\n"
+-        "std 4,   8(%0)\t\n"
+-        "std 5,  16(%0)\t\n"
+-        "std 6,  24(%0)\t\n"
+-        "std 7,  32(%0)\t\n"
+-        "std 8,  40(%0)\t\n"
+-        "std 9,  48(%0)\t\n"
+-        "std 10, 56(%0)\t\n"
+-        "stfd 1,   0(%1)\t\n"
+-        "stfd 2,   8(%1)\t\n"
+-        "stfd 3,  16(%1)\t\n"
+-        "stfd 4,  24(%1)\t\n"
+-        "stfd 5,  32(%1)\t\n"
+-        "stfd 6,  40(%1)\t\n"
+-        "stfd 7,  48(%1)\t\n"
+-        "stfd 8,  56(%1)\t\n"
+-        "stfd 9,  64(%1)\t\n"
+-        "stfd 10, 72(%1)\t\n"
+-        "stfd 11, 80(%1)\t\n"
+-        "stfd 12, 88(%1)\t\n"
+-        "stfd 13, 96(%1)\t\n"
+-	: : "r" (gpreg), "r" (fpreg) 
+-        : "r0", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10",
+-          "fr1", "fr2", "fr3", "fr4", "fr5", "fr6", "fr7", "fr8", "fr9",
++        "stfd 1,   0(%0)\t\n"
++        "stfd 2,   8(%0)\t\n"
++        "stfd 3,  16(%0)\t\n"
++        "stfd 4,  24(%0)\t\n"
++        "stfd 5,  32(%0)\t\n"
++        "stfd 6,  40(%0)\t\n"
++        "stfd 7,  48(%0)\t\n"
++        "stfd 8,  56(%0)\t\n"
++        "stfd 9,  64(%0)\t\n"
++        "stfd 10, 72(%0)\t\n"
++        "stfd 11, 80(%0)\t\n"
++        "stfd 12, 88(%0)\t\n"
++        "stfd 13, 96(%0)\t\n"
++    : : "r" (fpreg)
++        : "fr1", "fr2", "fr3", "fr4", "fr5", "fr6", "fr7", "fr8", "fr9",
+           "fr10", "fr11", "fr12", "fr13"
+     );
+ 
+-    volatile long sp;
+-
+-    //stack pointer
+-    __asm__ __volatile__ (
+-                "mr     %0,    1\n\t"
+-                : "=r" (sp) : );
+-
++    register long r11 asm("r11");
++    const long nOffsetAndIndex = r11;
++
++    register long r1 asm("r1");
++    const long sp = r1;
++
++#if defined(_CALL_ELF) && _CALL_ELF == 2
++    volatile long nRegReturn[2];
++#else
+     volatile long nRegReturn[1];
++#endif
+ 
+     typelib_TypeClass aType =
+         cpp_mediate( nOffsetAndIndex, (void**)gpreg, (void**)fpreg, sp, (sal_Int64*)nRegReturn);
+@@ -591,11 +599,20 @@
+         default:
+             __asm__( "ld 3,%0\n\t" 
+                 : : "m" (nRegReturn[0]) );
++#if defined(_CALL_ELF) && _CALL_ELF == 2
++            __asm__( "ld 4,%0\n\t"
++                : : "m" (nRegReturn[1]) );
++#endif
+             break;
+     }
+ }
+-
++#endif
++
++#if defined(_CALL_ELF) && _CALL_ELF == 2
++const int codeSnippetSize = 32;
++#else
+ const int codeSnippetSize = 24;
++#endif
+ 
+ unsigned char *  codeSnippet( unsigned char * code, sal_Int32 nFunctionIndex, sal_Int32 nVtableOffset, 
+                               bool simpleRetType)
+@@ -609,10 +626,22 @@
+ 
+     if ( !simpleRetType )
+         nOffsetAndIndex |= 0x80000000;
+-
++#if defined(_CALL_ELF) && _CALL_ELF == 2
++    unsigned int *raw = (unsigned int *)&code[0];
++
++    raw[0] = 0xe96c0018;        /* 0:   ld      11,2f-0b(12)    */
++    raw[1] = 0xe98c0010;        /*      ld      12,1f-0b(12)    */
++    raw[2] = 0x7d8903a6;        /*      mtctr   12              */
++    raw[3] = 0x4e800420;        /*      bctr                    */
++                                /* 1:   .quad   function_addr   */
++                                /* 2:   .quad   context         */
++    *(void **)&raw[4] = (void *)privateSnippetExecutor;
++    *(void **)&raw[6] = (void*)nOffsetAndIndex;
++#else
+     void ** raw = (void **)&code[0];
+     memcpy(raw, (char*) privateSnippetExecutor, 16);
+     raw[2] = (void*) nOffsetAndIndex;
++#endif
+ #ifdef CMC_DEBUG
+     fprintf(stderr, "in: offset/index is %x %x %d, %lx\n", 
+ 	nFunctionIndex, nVtableOffset, !simpleRetType, raw[2]);
+
diff --git a/editors/openoffice-4/files/patch-bridges_source_cpp__uno_gcc3__freebsd__powerpc64_makefile.mk b/editors/openoffice-4/files/patch-bridges_source_cpp__uno_gcc3__freebsd__powerpc64_makefile.mk
new file mode 100644
index 000000000000..a4be2365fe34
--- /dev/null
+++ b/editors/openoffice-4/files/patch-bridges_source_cpp__uno_gcc3__freebsd__powerpc64_makefile.mk
@@ -0,0 +1,21 @@
+--- bridges/source/cpp_uno/gcc3_freebsd_powerpc64/makefile.mk
++++ bridges/source/cpp_uno/gcc3_freebsd_powerpc64/makefile.mk
+@@ -53,7 +53,8 @@
+ SLOFILES= \
+ 	$(SLO)$/except.obj		\
+ 	$(SLO)$/cpp2uno.obj		\
+-	$(SLO)$/uno2cpp.obj
++	$(SLO)$/uno2cpp.obj		\
++	$(SLO)$/call.obj
+ 
+ SHL1TARGET= $(TARGET)
+ 
+@@ -73,3 +74,7 @@
+ # --- Targets ------------------------------------------------------
+ 
+ .INCLUDE :  target.mk
++
++$(SLO)$/%.obj: %.s
++    $(CC) -c -o $(SLO)$/$(@:b).o $<
++    touch $@
+
diff --git a/editors/openoffice-4/files/patch-bridges_source_cpp__uno_gcc3__freebsd__powerpc64_share.hxx b/editors/openoffice-4/files/patch-bridges_source_cpp__uno_gcc3__freebsd__powerpc64_share.hxx
index b36fd8309b2f..20311ea847f2 100644
--- a/editors/openoffice-4/files/patch-bridges_source_cpp__uno_gcc3__freebsd__powerpc64_share.hxx
+++ b/editors/openoffice-4/files/patch-bridges_source_cpp__uno_gcc3__freebsd__powerpc64_share.hxx
@@ -1,6 +1,65 @@
---- bridges/source/cpp_uno/gcc3_freebsd_powerpc64/share.hxx.orig	2020-10-06 14:16:16 UTC
+--- bridges/source/cpp_uno/gcc3_freebsd_powerpc64/share.hxx.orig
 +++ bridges/source/cpp_uno/gcc3_freebsd_powerpc64/share.hxx
-@@ -35,6 +35,7 @@ namespace CPPU_CURRENT_NAMESPACE
+@@ -25,16 +25,64 @@
+ 
+ #include <typeinfo>
+ #include <exception>
++
++#include <cxxabi.h>
++#ifndef _GLIBCXX_CDTOR_CALLABI // new in GCC 4.7 cxxabi.h
++#define _GLIBCXX_CDTOR_CALLABI
++#endif
+ #include <cstddef>
++
++#ifndef CONFIG_CXXABI_H
++#define CONFIG_CXXABI_H
++
++#define HAVE_CXXABI_H_BASE_CLASS_TYPE_INFO 0
++#define HAVE_CXXABI_H_CLASS_TYPE_INFO 0
++#define HAVE_CXXABI_H_CXA_ALLOCATE_EXCEPTION 0
++#define HAVE_CXXABI_H_CXA_EH_GLOBALS 1
++#define HAVE_CXXABI_H_CXA_EXCEPTION 1
++#define HAVE_CXXABI_H_CXA_GET_GLOBALS 1
++#define HAVE_CXXABI_H_CXA_CURRENT_EXCEPTION_TYPE 1
++#define HAVE_CXXABI_H_CXA_THROW 0
++#define HAVE_CXXABI_H_SI_CLASS_TYPE_INFO 0
++#define HAVE_CXXABI_H_VMI_CLASS_TYPE_INFO 0
++
++#endif
++
++#if !HAVE_CXXABI_H_CLASS_TYPE_INFO
++// <https://mentorembedded.github.io/cxx-abi/abi.html>,
++// libstdc++-v3/libsupc++/cxxabi.h:
++namespace __cxxabiv1 {
++class __class_type_info: public std::type_info {
++public:
++    explicit __class_type_info(char const * n): type_info(n) {}
++    ~__class_type_info();
++};
++}
++#endif
++
++#if !HAVE_CXXABI_H_SI_CLASS_TYPE_INFO
++// <https://mentorembedded.github.io/cxx-abi/abi.html>,
++// libstdc++-v3/libsupc++/cxxabi.h:
++namespace __cxxabiv1 {
++class __si_class_type_info: public __class_type_info {
++public:
++    __class_type_info const * __base_type;
++    explicit __si_class_type_info(
++        char const * n, __class_type_info const *base):
++        __class_type_info(n), __base_type(base) {}
++    ~__si_class_type_info();
++};
++}
++#endif
+ 
+ namespace CPPU_CURRENT_NAMESPACE
+ {
+ 
+-  void dummy_can_throw_anything( char const * );
+-
++void dummy_can_throw_anything( char const * );
  
  // ----- following decl from libstdc++-v3/libsupc++/unwind-cxx.h and unwind.h
  
@@ -8,15 +67,14 @@
  struct _Unwind_Exception
  {
      unsigned exception_class __attribute__((__mode__(__DI__)));
-@@ -63,18 +64,21 @@ struct __cxa_exception
+@@ -63,18 +111,21 @@
      
      _Unwind_Exception unwindHeader;
  };    
 +#endif /* __GLIBCXX__ */
  
  extern "C" void *__cxa_allocate_exception(
--    std::size_t thrown_size ) throw();
-+    size_t thrown_size );
+     std::size_t thrown_size ) throw();
  extern "C" void __cxa_throw (
      void *thrown_exception, std::type_info *tinfo, void (*dest) (void *) ) __attribute__((noreturn));
  
@@ -31,7 +89,7 @@
  
  // -----
  
-@@ -82,6 +86,10 @@ void raiseException(
+@@ -82,11 +133,16 @@
  void raiseException(
      uno_Any * pUnoExc, uno_Mapping * pUno2Cpp );
  //==================================================================================================
@@ -42,3 +100,11 @@
  void fillUnoException(
      __cxa_exception * header, uno_Any *, uno_Mapping * pCpp2Uno );
  }
+ 
+ namespace ppc64
+ {
+-	enum ppclimits { MAX_GPR_REGS = 8, MAX_SSE_REGS = 13 };
++     enum ppclimits { MAX_GPR_REGS = 8, MAX_SSE_REGS = 13 };
++    bool return_in_hidden_param( typelib_TypeDescriptionReference *pTypeRef );
+ }
+
diff --git a/editors/openoffice-4/files/patch-bridges_source_cpp__uno_gcc3__freebsd__powerpc64_uno2cpp.cxx b/editors/openoffice-4/files/patch-bridges_source_cpp__uno_gcc3__freebsd__powerpc64_uno2cpp.cxx
index 205333ecb78c..3ed19a042123 100644
--- a/editors/openoffice-4/files/patch-bridges_source_cpp__uno_gcc3__freebsd__powerpc64_uno2cpp.cxx
+++ b/editors/openoffice-4/files/patch-bridges_source_cpp__uno_gcc3__freebsd__powerpc64_uno2cpp.cxx
@@ -1,9 +1,24 @@
---- bridges/source/cpp_uno/gcc3_freebsd_powerpc64/uno2cpp.cxx.orig	2019-09-17 22:55:10 UTC
+--- bridges/source/cpp_uno/gcc3_freebsd_powerpc64/uno2cpp.cxx.orig
 +++ bridges/source/cpp_uno/gcc3_freebsd_powerpc64/uno2cpp.cxx
-@@ -42,6 +42,14 @@ using namespace ::com::sun::star::uno;
+@@ -26,6 +26,12 @@
+ 
+ #include <stdlib.h>
+ 
++#include <exception>
++#include <malloc.h>
++#include <typeinfo>
++
++#include <com/sun/star/uno/Exception.hpp>
++#include <com/sun/star/uno/RuntimeException.hpp>
+ #include <com/sun/star/uno/genfunc.hxx>
+ #include <uno/data.h>
+ 
+@@ -42,10 +48,68 @@
  
  using namespace ::rtl;
  using namespace ::com::sun::star::uno;
+-
+-void MapReturn(long r3, double dret, typelib_TypeClass eTypeClass, void *pRegisterReturn)
 +#ifdef __GLIBCXX__
 +using CPPU_CURRENT_NAMESPACE::__cxa_exception;
 +using CPPU_CURRENT_NAMESPACE::__cxa_get_globals;
@@ -12,10 +27,332 @@
 +using __cxxabiv1::__cxa_current_primary_exception;
 +using __cxxabiv1::__cxa_decrement_exception_refcount;
 +#endif
- 
- void MapReturn(long r3, double dret, typelib_TypeClass eTypeClass, void *pRegisterReturn)
++
++namespace ppc64
  {
-@@ -448,9 +456,18 @@ static void cpp_call(
+-    switch (eTypeClass)
++#if defined(_CALL_ELF) && _CALL_ELF == 2
++    bool is_complex_struct(const typelib_TypeDescription * type)
*** 1864 LINES SKIPPED ***