public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Alan Modra <amodra@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r11-3418] [RS6000] Power10 libffi fixes Date: Thu, 24 Sep 2020 03:23:06 +0000 (GMT) [thread overview] Message-ID: <20200924032306.ADA2139518A8@sourceware.org> (raw) https://gcc.gnu.org/g:08cd8d5929eac84b27788d8483fd75ab7ad13129 commit r11-3418-g08cd8d5929eac84b27788d8483fd75ab7ad13129 Author: Alan Modra <amodra@gmail.com> Date: Fri Sep 18 23:21:05 2020 +0930 [RS6000] Power10 libffi fixes 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. * src/powerpc/linux64.S (ffi_call_LINUX64): Don't emit global entry when __PCREL__. Call using @notoc. Add nops. * src/powerpc/linux64_closure.S (ffi_closure_LINUX64): Likewise. (ffi_go_closure_linux64): Likewise. Diff: --- libffi/src/powerpc/linux64.S | 8 ++++++++ libffi/src/powerpc/linux64_closure.S | 12 +++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/libffi/src/powerpc/linux64.S b/libffi/src/powerpc/linux64.S index b2ae60ead6e..f0006fe90c5 100644 --- a/libffi/src/powerpc/linux64.S +++ b/libffi/src/powerpc/linux64.S @@ -36,8 +36,10 @@ .cfi_startproc # if _CALL_ELF == 2 ffi_call_LINUX64: +# ifndef __PCREL__ addis %r2, %r12, .TOC.-ffi_call_LINUX64@ha addi %r2, %r2, .TOC.-ffi_call_LINUX64@l +# endif .localentry ffi_call_LINUX64, . - ffi_call_LINUX64 # else .section ".opd","aw" @@ -89,9 +91,15 @@ ffi_call_LINUX64: /* Call ffi_prep_args64. */ mr %r4, %r1 # if defined _CALL_LINUX || _CALL_ELF == 2 +# ifdef __PCREL__ + bl ffi_prep_args64@notoc +# else bl ffi_prep_args64 + nop +# endif # else bl .ffi_prep_args64 + nop # endif # if _CALL_ELF == 2 diff --git a/libffi/src/powerpc/linux64_closure.S b/libffi/src/powerpc/linux64_closure.S index 6487d2a2970..3e30db36190 100644 --- a/libffi/src/powerpc/linux64_closure.S +++ b/libffi/src/powerpc/linux64_closure.S @@ -37,8 +37,10 @@ .cfi_startproc # if _CALL_ELF == 2 ffi_closure_LINUX64: +# ifndef __PCREL__ addis %r2, %r12, .TOC.-ffi_closure_LINUX64@ha addi %r2, %r2, .TOC.-ffi_closure_LINUX64@l +# endif .localentry ffi_closure_LINUX64, . - ffi_closure_LINUX64 # else .section ".opd","aw" @@ -143,7 +145,7 @@ ffi_closure_LINUX64: stfd %f12, -104+(11*8)(%r1) stfd %f13, -104+(12*8)(%r1) - # load up the pointer to the saved fpr registers */ + # load up the pointer to the saved fpr registers addi %r8, %r1, -104 # load up the pointer to the result storage @@ -155,9 +157,15 @@ ffi_closure_LINUX64: # make the call # if defined _CALL_LINUX || _CALL_ELF == 2 +# ifdef __PCREL__ + bl ffi_closure_helper_LINUX64@notoc +# else bl ffi_closure_helper_LINUX64 + nop +# endif # else bl .ffi_closure_helper_LINUX64 + nop # endif .Lret: @@ -396,8 +404,10 @@ ffi_closure_LINUX64: .cfi_startproc # if _CALL_ELF == 2 ffi_go_closure_linux64: +# ifndef __PCREL__ addis %r2, %r12, .TOC.-ffi_go_closure_linux64@ha addi %r2, %r2, .TOC.-ffi_go_closure_linux64@l +# endif .localentry ffi_go_closure_linux64, . - ffi_go_closure_linux64 # else .section ".opd","aw"
reply other threads:[~2020-09-24 3:23 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20200924032306.ADA2139518A8@sourceware.org \ --to=amodra@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).