office-gobmx/bridges
Stephan Bergmann 252aba41e5 Replace brittle gcc3_linux_aarch64 vtableSlotCall with pure assembler code
*  For one, as discussed in the comment at <https://gerrit.libreoffice.org/c/
core/+/91978/2#message-97da6c6ece7ae7bd49e9eb4843be333192fcc057> "Port to
FreeBSD aarch64":

"So it looks like Clang does not treat those register asm as we expect it would,
at least on aarch64.

"Witness a local Linux recent master --with-distro=LibreOfficeAndroidAarch64
[i.e., using Clang] build's

> $ llvm-objdump --disassemble instdir/program/libgcc3_uno.a
[...]
> 0000000000000000 <vtableSlotCall>:
>        0: ff 43 03 d1   sub     sp, sp, #208
>        4: f4 4f 0b a9   stp     x20, x19, [sp, #176]
>        8: fd 7b 0c a9   stp     x29, x30, [sp, #192]
>        c: fd 03 03 91   add     x29, sp, #192
>       10: a8 43 00 91   add     x8, x29, #16
>       14: bf 83 1d f8   stur    xzr, [x29, #-40]
>       18: e0 07 04 a9   stp     x0, x1, [sp, #64]
>       1c: e2 0f 05 a9   stp     x2, x3, [sp, #80]
>       20: e4 17 06 a9   stp     x4, x5, [sp, #96]
>       24: e6 1f 07 a9   stp     x6, x7, [sp, #112]
>       28: e0 07 00 6d   stp     d0, d1, [sp]
>       2c: e2 0f 01 6d   stp     d2, d3, [sp, #16]
>       30: e4 17 02 6d   stp     d4, d5, [sp, #32]
>       34: e6 1f 03 6d   stp     d6, d7, [sp, #48]
>       38: a8 03 1c f8   stur    x8, [x29, #-64]
>       3c: a0 43 5e b8   ldur    w0, [x29, #-28]
>       40: a1 03 5e b8   ldur    w1, [x29, #-32]
>       44: a5 83 5e f8   ldur    x5, [x29, #-24]
>       48: e4 03 08 aa   mov     x4, x8
>       4c: e2 03 01 91   add     x2, sp, #64
>       50: e3 03 00 91   mov     x3, sp
>       54: f3 03 01 91   add     x19, sp, #64
>       58: f4 03 00 91   mov     x20, sp
>       5c: 00 00 00 94   bl      0x5c <vtableSlotCall+0x5c>
>       60: 60 06 40 a9   ldp     x0, x1, [x19]
>       64: 80 06 40 6d   ldp     d0, d1, [x20]
>       68: 82 0e 41 6d   ldp     d2, d3, [x20, #16]
>       6c: fd 7b 4c a9   ldp     x29, x30, [sp, #192]
>       70: f4 4f 4b a9   ldp     x20, x19, [sp, #176]
>       74: ff 43 03 91   add     sp, sp, #208
>       78: c0 03 5f d6   ret
[...]

vs. [this commit's vtableslotcall.s; see below for details].

"And also latest Clang 12 trunk still does e.g.

> $ cat test.c
> void f(long);
> void g() {
>     register long volatile a asm ("x8");
>     f(a);
> }
> $ clang --target=unknown-linux-aarch64 -S -O2 test.c
> $ cat test.s
>         .text
>         .file   "test.c"
>         .globl  g                               // -- Begin function g
>         .p2align        2
>         .type   g,@function
> g:                                      // @g
> // %bb.0:                               // %entry
>         sub     sp, sp, #16                     // =16
>         ldr     x0, [sp, #8]
>         add     sp, sp, #16                     // =16
>         b       f
> .Lfunc_end0:
>         .size   g, .Lfunc_end0-g
>                                         // -- End function
>         .ident  "clang version 12.0.0 (git@github.com:llvm/llvm-project eb31ddd71eb44d53ebe12a09c9587198bb6f2a2e)"
>         .section        ".note.GNU-stack","",@progbits
>         .addrsig

"(This is probably also the underlying issue that
eb15ac837e 'android: Avoid throwing exceptions
through the bridges' tries to hack arond.)"

*  For another, this also gets rid of the
dddb527db1 "Again, no -fstack-protector-strong for
gcc3_linux_aarch64/cpp2uno.cxx" hack.

The contents of the new vtableslotcall.s is effectively the GCC 10 -S output of
the old vtableSlotCall C++ function from cpp2uno.cxx.  (And as cpp2uno.cxx only
takes the address of vtableSlotCall, never calls it directly, it does not matter
that it declares it with an imprecise

  extern "C" void vtableSlotCall();

signature.)

Change-Id: Icfbf0622a47825ff7cf21008de27d3da6a2f0ebd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99660
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2020-07-29 09:56:02 +02:00
..
inc
source
CustomTarget_gcc3_linux_arm.mk
Jar_java_uno.mk
Library_cpp_uno.mk
Library_java_uno.mk
Makefile
Module_bridges.mk
Package_jnilib_java_uno.mk
README

Bridges from various C++ ABIs, Java JNI, MS .Net to UNO and back.

Also implementation of the UNO Remote Protocol. And in ooo-build a bridge from Mono to UNO and back.