]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/6l: use .plt instead of .got on Solaris
authorAram Hăvărneanu <aram@mgk.ro>
Mon, 30 Mar 2015 11:46:28 +0000 (13:46 +0200)
committerAram Hăvărneanu <aram@mgk.ro>
Wed, 6 May 2015 11:36:39 +0000 (11:36 +0000)
Solaris requires all external procedures to be accessed through the
PLT. If 6l won't do it, /bin/ld will, so all the code written with .GOT
in mind won't work with the external linker.

This CL makes external linking work, opening the path to cgo support
on Solaris.

This CL breaks the Solaris build, this is fixed in subsequent CLs in
this series.

Change-Id: If370a79f49fdbe66d28b89fa463b4f3e91685f69
Reviewed-on: https://go-review.googlesource.com/8214
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
src/cmd/6l/asm.go

index 4df8ac719645ec630855b1dd3fe50dbdb2dd7d0f..a025ce6ea634042cf67adde683b7fb0ccf4de211 100644 (file)
@@ -272,6 +272,12 @@ func adddynrel(s *ld.LSym, r *ld.Reloc) {
 
        case obj.R_ADDR:
                if s.Type == obj.STEXT && ld.Iself {
+                       if ld.HEADTYPE == obj.Hsolaris {
+                               addpltsym(targ)
+                               r.Sym = ld.Linklookup(ld.Ctxt, ".plt", 0)
+                               r.Add += int64(targ.Plt)
+                               return
+                       }
                        // The code is asking for the address of an external
                        // function.  We provide it with the address of the
                        // correspondent GOT symbol.