]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link: check for power10 support on external linker for PPC64
authorPaul E. Murphy <murp@ibm.com>
Mon, 20 Feb 2023 15:21:32 +0000 (09:21 -0600)
committerPaul Murphy <murp@ibm.com>
Mon, 27 Feb 2023 14:57:47 +0000 (14:57 +0000)
The external linker will need to support the new PC relative relocations
when they are generated by Go in a future patch. If it does not, many
unhelpful relocation errors will be generated by the external linker.

Use the -mcpu=power10 option as a surrogate for -mpcrel. It most cases,
it should indicate whether the underlying linker has support for
resolving PC relative relocations.

Change-Id: I84b151ce04512ccaeb17835aaf44105a5f6b515b
Reviewed-on: https://go-review.googlesource.com/c/go/+/469576
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Paul Murphy <murp@ibm.com>
Reviewed-by: Archana Ravindar <aravind5@in.ibm.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
src/cmd/link/internal/ld/lib.go

index d96f13225642766e9bbebc3ae589d897e5b60fa4..b64176e35dd1c3783b08b5649d1fed23ca7cdfac 100644 (file)
@@ -1418,6 +1418,16 @@ func (ctxt *Link) hostlink() {
                argv = append(argv, "-Wl,-bbigtoc")
        }
 
+       // On PPC64, verify the external toolchain supports Power10. This is needed when
+       // PC relative relocations might be generated by Go. Only targets compiling ELF
+       // binaries might generate these relocations.
+       if ctxt.IsPPC64() && ctxt.IsElf() && buildcfg.GOPPC64 >= 10 {
+               if !linkerFlagSupported(ctxt.Arch, argv[0], "", "-mcpu=power10") {
+                       Exitf("The external toolchain does not support -mcpu=power10. " +
+                               " This is required to externally link GOPPC64 >= power10")
+               }
+       }
+
        // Enable/disable ASLR on Windows.
        addASLRargs := func(argv []string, val bool) []string {
                // Old/ancient versions of GCC support "--dynamicbase" and