[libreoffice] fix UNO bridges for ppc and ppc64
David Tardon
dtardon at fedoraproject.org
Mon Apr 23 12:06:35 UTC 2012
commit 16611a273cadfbc5daf16bd3dc004f4a6ba0ea18
Author: David Tardon <dtardon at redhat.com>
Date: Mon Apr 23 14:06:15 2012 +0200
fix UNO bridges for ppc and ppc64
...gcc-use-registers-we-are-setting-ourselve.patch | 54 ++++++++++++++++++
0001-save-register-arguments-first.patch | 57 ++++++++++++++++++++
libreoffice.spec | 5 ++
3 files changed, 116 insertions(+), 0 deletions(-)
---
diff --git a/0001-do-not-let-gcc-use-registers-we-are-setting-ourselve.patch b/0001-do-not-let-gcc-use-registers-we-are-setting-ourselve.patch
new file mode 100644
index 0000000..a94a66a
--- /dev/null
+++ b/0001-do-not-let-gcc-use-registers-we-are-setting-ourselve.patch
@@ -0,0 +1,54 @@
+From 032084d8582ef8eb04724d2488f3e381ac8054d2 Mon Sep 17 00:00:00 2001
+From: David Tardon <dtardon at redhat.com>
+Date: Mon, 23 Apr 2012 13:19:39 +0200
+Subject: [PATCH] do not let gcc use registers we are setting ourselves
+
+gcc uses a register for the function call--and it tried r9 here...
+---
+ .../source/cpp_uno/gcc3_linux_powerpc/uno2cpp.cxx | 16 +++++++++++++---
+ 1 files changed, 13 insertions(+), 3 deletions(-)
+
+diff --git a/bridges/source/cpp_uno/gcc3_linux_powerpc/uno2cpp.cxx b/bridges/source/cpp_uno/gcc3_linux_powerpc/uno2cpp.cxx
+index 34e8c63..f409bf7 100644
+--- a/bridges/source/cpp_uno/gcc3_linux_powerpc/uno2cpp.cxx
++++ b/bridges/source/cpp_uno/gcc3_linux_powerpc/uno2cpp.cxx
+@@ -67,7 +67,6 @@ static void callVirtualMethod(
+ // of floating point registers f1 to f8
+
+ unsigned long * mfunc; // actual function to be invoked
+- void (*ptr)();
+ int gpr[8]; // storage for gpregisters, map to r3-r10
+ int off; // offset used to find function
+ #ifndef __NO_FPRS__
+@@ -243,7 +242,8 @@ static void callVirtualMethod(
+ mfunc = *((unsigned long **)pAdjustedThisPtr); // get the address of the vtable
+ mfunc = (unsigned long *)((char *)mfunc + off); // get the address from the vtable entry at offset
+ mfunc = *((unsigned long **)mfunc); // the function is stored at the address
+- ptr = (void (*)())mfunc;
++ typedef void (*FunctionCall)(sal_uInt32, sal_uInt32, sal_uInt32, sal_uInt32, sal_uInt32, sal_uInt32, sal_uInt32, sal_uInt32);
++ FunctionCall ptr = (FunctionCall)mfunc;
+
+ /* Set up the machine registers and invoke the function */
+
+@@ -272,7 +272,17 @@ static void callVirtualMethod(
+ : "0", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"
+ );
+
+- (*ptr)();
++ // tell gcc that r3 to r10 are not available to it for doing the TOC and exception munge on the func call
++ register sal_uInt32 r3 __asm__("r3");
++ register sal_uInt32 r4 __asm__("r4");
++ register sal_uInt32 r5 __asm__("r5");
++ register sal_uInt32 r6 __asm__("r6");
++ register sal_uInt32 r7 __asm__("r7");
++ register sal_uInt32 r8 __asm__("r8");
++ register sal_uInt32 r9 __asm__("r9");
++ register sal_uInt32 r10 __asm__("r10");
++
++ (*ptr)(r3, r4, r5, r6, r7, r8, r9, r10);
+
+ __asm__ __volatile__ (
+ "mr %0, 3\n\t"
+--
+1.7.7.6
+
diff --git a/0001-save-register-arguments-first.patch b/0001-save-register-arguments-first.patch
new file mode 100644
index 0000000..dd5989d
--- /dev/null
+++ b/0001-save-register-arguments-first.patch
@@ -0,0 +1,57 @@
+From f4c5fe13fd1484aa1bf37910841c689877740602 Mon Sep 17 00:00:00 2001
+From: David Tardon <dtardon at redhat.com>
+Date: Mon, 23 Apr 2012 09:47:41 +0200
+Subject: [PATCH] save register arguments first
+
+The "mr" stores r11 to indeterminate register (r9 in my case) before
+storing it into the output variable, thus overwriting one of our input
+arguments... This later leads to nice segfault in
+testtools/source/bridgetest ...
+
+I suppose there is a better way to get the variable, but I do not know
+it .-)
+---
+ .../cpp_uno/gcc3_linux_powerpc64/cpp2uno.cxx | 16 ++++++++--------
+ 1 files changed, 8 insertions(+), 8 deletions(-)
+
+diff --git a/bridges/source/cpp_uno/gcc3_linux_powerpc64/cpp2uno.cxx b/bridges/source/cpp_uno/gcc3_linux_powerpc64/cpp2uno.cxx
+index 425c5b5..3cb94dd 100644
+--- a/bridges/source/cpp_uno/gcc3_linux_powerpc64/cpp2uno.cxx
++++ b/bridges/source/cpp_uno/gcc3_linux_powerpc64/cpp2uno.cxx
+@@ -504,13 +504,6 @@ static typelib_TypeClass cpp_mediate(
+
+ extern "C" void privateSnippetExecutor( ... )
+ {
+- volatile long nOffsetAndIndex;
+-
+- //mr %r3, %r11 # move into arg1 the 64bit value passed from OOo
+- __asm__ __volatile__ (
+- "mr %0, 11\n\t"
+- : "=r" (nOffsetAndIndex) : );
+-
+ sal_uInt64 gpreg[ppc64::MAX_GPR_REGS];
+ double fpreg[ppc64::MAX_SSE_REGS];
+
+@@ -537,11 +530,18 @@ extern "C" void privateSnippetExecutor( ... )
+ "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",
++ : "r0", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11",
+ "fr1", "fr2", "fr3", "fr4", "fr5", "fr6", "fr7", "fr8", "fr9",
+ "fr10", "fr11", "fr12", "fr13"
+ );
+
++ volatile long nOffsetAndIndex;
++
++ //mr %r3, %r11 # move into arg1 the 64bit value passed from OOo
++ __asm__ __volatile__ (
++ "mr %0, 11\n\t"
++ : "=r" (nOffsetAndIndex) : );
++
+ volatile long sp;
+
+ //stack pointer
+--
+1.7.7.6
+
diff --git a/libreoffice.spec b/libreoffice.spec
index c0e005f..beb32dc 100644
--- a/libreoffice.spec
+++ b/libreoffice.spec
@@ -141,6 +141,8 @@ Patch27: 0001-Resolves-rhbz-806663-SlideshowImpl-can-outlive-SdMod.patch
Patch28: 0001-desktop-do-not-complain-about-soffice-command-line-o.patch
Patch29: 0001-Resolves-fdo-48096-torn-off-popups-trigger-keyboard-.patch
Patch30: 0001-fdo-38088-better-CSV-import-default-separators.patch
+Patch31: 0001-save-register-arguments-first.patch
+Patch32: 0001-do-not-let-gcc-use-registers-we-are-setting-ourselve.patch
%{!?python_sitearch: %global python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")}
%define instdir %{_libdir}
@@ -993,6 +995,8 @@ mv -f redhat.soc extras/source/palettes/standard.soc
%patch28 -p1 -b .do-not-complain-about-soffice-command-line-o.patch
%patch29 -p1 -b .fdo48096-torn-off-popups-trigger-keyboard-.patch
%patch30 -p1 -b .fdo-38088-better-CSV-import-default-separators.patch
+%patch31 -p1 -b .save-register-arguments-first.patch
+%patch32 -p1 -b .do-not-let-gcc-use-registers-we-are-setting-ourselve.patch
# TODO: check this
# these are horribly incomplete--empty translations and copied english
@@ -2282,6 +2286,7 @@ update-desktop-database %{_datadir}/applications &> /dev/null || :
%changelog
* Mon Apr 23 2012 David Tardon <dtardon at redhat.com> - 3.5.3.1-2
- rebuild for icu
+- fix UNO bridges for ppc and ppc64
* Thu Apr 19 2012 David Tardon <dtardon at redhat.com> - 3.5.3.1-1
- 3.5.3 rc1
More information about the scm-commits
mailing list