[RS6000] Power10 libffi fixes
Segher Boessenkool
segher@kernel.crashing.org
Wed Sep 23 00:16:57 GMT 2020
Hi!
On Tue, Sep 22, 2020 at 10:00:11AM +0930, Alan Modra wrote:
> Power10 pc-relative code doesn't use or preserve r2 as a TOC pointer.
> That means calling between pc-relative and TOC using code can't be
> done without intervening linker stubs, and a call from TOC code to
> pc-relative code must have a nop after the bl in order to restore r2.
>
> Now the PowerPC libffi assembly code doesn't use r2 except for the
> implicit use when making calls back to C, ffi_closure_helper_LINUX64
> and ffi_prep_args64. So changing the assembly to interoperate with
> pc-relative code without stubs is easily done. Controlling that is a
> new built-in macro.
>
> Upstream libffi currently has a different patch applied to work around
> the power10 build failure. I'll post a delta for upstream.
> Bootstrapped and regression tested on power8, built for power10.
>
> gcc/
> * config/rs6000/rs6000-c.c (rs6000_target_modify_macros):
> Conditionally define __PCREL__.
Please do that as a separate (earlier) patch (because it *is*, and to
simplify backports, etc).
> libffi/
> * src/powerpc/linux64.S (ffi_call_LINUX64): Don't emit global
> entry when __PCREL__. Call using @notoc.
> (ffi_closure_LINUX64, ffi_go_closure_linux64): Likewise.
This is okay for trunk, and for backports (possibly expedited, talk
with Peter for what is wanted/needed for AT).
Thanks!
Segher
More information about the Gcc-patches
mailing list