Repository navigation
FreeBSD PowerPC64: fix the C++-UNO bridge, build on little-endian - #512
Conversation
call.s was generated by gcc on a glibc system with -fstack-protector, so callVirtualMethod and privateSnippetExecutor keep their stack canary at -28688(r13), the slot where glibc stores the stack guard. On FreeBSD that slot is the first word of the thread control block, the DTV pointer. rtld replaces the DTV when a thread first uses TLS after a library with TLS was loaded, so a bridged call during which that happens fails the check and aborts in __stack_chk_fail. Saving a document from Python over the URP bridge was enough to trigger it. Remove the canary code from both functions. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
The bridge used a hidden return pointer for every struct, but under the ELFv2 ABI structs of up to 16 bytes come back in r3/r4, and structs made of up to eight floats or doubles come back in f1-f8. Calling a C++ method that returns such a struct from Basic, Python or Java, e.g. getCellAddress() or getPosition(), passed the return buffer where the callee expected this, and the testtools bridgetest crashed. Use return_in_hidden_param() for both call directions and for the vtable snippets, pass f1-f8 to MapReturn(), and load f1-f8 in privateSnippetExecutor when a C++ caller expects such a float struct. With this the bridgetest passes on FreeBSD 15.1 powerpc64 and powerpc64le, in-process and over URP, against both the C++ and the Java test objects. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
source_soenv.sh only matched the powerpc64-*-freebsd* triplet, so on powerpc64le bootstrap stopped with "unknown *Env.Set.sh for: powerpc64le-unknown-freebsd15.1" even though configure had written FreeBSDPPC64Env.Set.sh. Match powerpc64le-*-freebsd* too. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
OpenJDK on powerpc64le keeps its native libraries under jre/lib/ppc64le, not jre/lib/ppc64, so on little-endian FreeBSD the linker looked for libjawt in a directory that doesn't exist. Pick the directory from the platform triplet. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
OpenJDK 8 on little-endian 64-bit PowerPC installs libjvm.so under jre/lib/ppc64le, so a Java 8 runtime was not recognized there. Use "ppc64le" as JFW_PLUGIN_ARCH when OSL_BIGENDIAN is not defined, like the MIPS entry does. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
|
Here is a quick review (from ChatGPT):
The new helper recursively collects structure members and accepts a structure when every leaf member is either float or double and all leaves have the same type. It limits the total to eight members. That is a useful starting point, but it does not verify the actual member layout or the absence of padding. The PowerPC64 ELFv2 ABI defines homogeneous aggregates in terms of the aggregate's layout as well as its element types; its specification explicitly excludes certain aggregates containing padding words. Kib The concern is that the bridge could classify a type as an HFA based on its members even when its memory layout does not match the sequence of floating-point values the bridge subsequently copies into or out of FPRs. Recommended change:
The patch changes both directions of the bridge:
|
|
FWIW, ChatGPT had other suggestions as well which are not critical. |
Two fixes for the FreeBSD powerpc64 C++-UNO bridge, plus what
powerpc64le needs to bootstrap and to find its JRE.
checks a canary at -28688(r13). On FreeBSD that slot holds the DTV
pointer, which rtld replaces when a thread first uses TLS after a
library with TLS was loaded, so a bridged call could abort in
__stack_chk_fail (saving a document from Python was enough).
of up to eight floats or doubles in f1-f8. The bridge used a hidden
return pointer for every struct, so Basic, Python and Java got
garbage from methods like getCellAddress(), and the bridgetest
crashed.
bootstrap failed on powerpc64le.
Testing, FreeBSD 15.1 powerpc64le, AOO 4.1.17 built by the FreeBSD port
(which carries this bridge as local patches) with these fixes:
and the Java test objects (the build skips it on FreeBSD PPC, so it
was run by hand from the build tree);
export and reload (odt/doc/pdf, ods/xls/csv, odg, odp/ppt), structs
returned by value (CellAddress, CellRangeAddress, Point, Size), C++
exceptions mapped to Python, a Python listener called back from the
office, a Basic macro;
FreeBSD 15.1 powerpc64 (big-endian), the same port and checks: the
bridgetest and the PyUNO script pass there too.
trunk at 430d157 on FreeBSD 15.1 powerpc64le, built by the FreeBSD
port editors/openoffice-devel (its local patches give the same files as
this series): it builds, and the same checks pass. The URP bridgetest
client needed -env:OOO_BASE_DIR set to the installed office, because
trunk's testtools services.rdb registers uuresolver under
$OOO_BASE_DIR/program. Since 430d157 the files this series touches
have changed only in unrelated places.
These changes were prepared with the help of an AI assistant (Claude);
the commits carry a Co-authored-by line as the ASF generative tooling
guidance suggests.