]> Cypherpunks repositories - gostls13.git/commit
cmd/link: generate PPC64 ABI register save/restore functions if needed
authorPaul E. Murphy <murp@ibm.com>
Fri, 15 Apr 2022 22:06:48 +0000 (17:06 -0500)
committerPaul Murphy <murp@ibm.com>
Fri, 6 May 2022 17:56:28 +0000 (17:56 +0000)
commit9c9090eb1da540c7d757df0c60423319a28759d3
treeb4f296409d38b8f55654d523cc47a34f2395f16d
parent4a5711c3cf944b3ff51af261166ef34b2ed22b8a
cmd/link: generate PPC64 ABI register save/restore functions if needed

They are usually needed when internally linking gcc code
compiled with -Os. These are typically generated by ld
or gold, but are missing when linking internally.

The PPC64 ELF ABI describes a set of functions to save/restore
non-volatile, callee-save registers using R1/R0/R12:

 _savegpr0_n: Save Rn-R31 relative to R1, save LR (in R0), return
 _restgpr0_n: Restore Rn-R31 from R1, and return to saved LR
  _savefpr_n: Save Fn-F31 based on R1, and save LR (in R0), return
  _restfpr_n: Restore Fn-F31 from R1, and return to 16(R1)
 _savegpr1_n: Save Rn-R31 based on R12, return
 _restgpr1_n: Restore Rn-R31 based on R12, return
   _savevr_m: Save VRm-VR31 based on R0, R12 is scratch, return
   _restvr_m: Restore VRm-VR31 based on R0, R12 is scratch, return

 m is a value 20<=m<=31
 n is a value 14<=n<=31

Add several new functions similar to those suggested by the
PPC64 ELFv2 ABI. And update the linker to scan external relocs
for these calls, and redirect them to runtime.elf_<func>+offset
in runtime/asm_ppc64x.go.

Similarly, code which generates plt stubs is moved into
a dedicated function. This avoids an extra scan of relocs.

fixes #52336

Change-Id: I2f0f8b5b081a7b294dff5c92b4b1db8eba9a9400
Reviewed-on: https://go-review.googlesource.com/c/go/+/400796
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
src/cmd/go/testdata/script/test_ppc64_linker_funcs.txt [new file with mode: 0644]
src/cmd/link/internal/ppc64/asm.go
src/runtime/asm_ppc64x.s