]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/internal/obj, cmd/link: darwin dynlink support
authorDavid Crawshaw <crawshaw@golang.org>
Mon, 19 Sep 2016 18:11:20 +0000 (14:11 -0400)
committerDavid Crawshaw <crawshaw@golang.org>
Tue, 20 Sep 2016 03:15:15 +0000 (03:15 +0000)
This makes it possible for cmd/compile, when run with -dynlink on
darwin/amd64, to generate TLS_LE relocations which the linker then
turns into the appropriate PC-relative GOT load.

Change-Id: I1a71da432608bdb108ff66c22de600100209c873
Reviewed-on: https://go-review.googlesource.com/29393
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/cmd/internal/obj/x86/asm6.go
src/cmd/link/internal/amd64/asm.go

index a4c9603534384ac0841a3cfef0c4bdabf36b274b..f1f8e6f26449662e799b06535a8bf7774321fd3a 100644 (file)
@@ -2769,7 +2769,7 @@ func vaddr(ctxt *obj.Link, p *obj.Prog, a *obj.Addr, r *obj.Reloc) int64 {
                        log.Fatalf("reloc")
                }
 
-               if !ctxt.Flag_shared || isAndroid {
+               if !ctxt.Flag_shared || isAndroid || ctxt.Headtype == obj.Hdarwin {
                        r.Type = obj.R_TLS_LE
                        r.Siz = 4
                        r.Off = -1 // caller must fill in
index f074dbe6f97c2f1d3b3530c51d59f4e92493b974..2de86ea1dbdc3b008bab57452a0540cc33e5a276 100644 (file)
@@ -425,7 +425,7 @@ func machoreloc1(s *ld.Symbol, r *ld.Reloc, sectoff int64) int {
 
        rs := r.Xsym
 
-       if rs.Type == obj.SHOSTOBJ || r.Type == obj.R_PCREL {
+       if rs.Type == obj.SHOSTOBJ || r.Type == obj.R_PCREL || r.Type == obj.R_GOTPCREL {
                if rs.Dynid < 0 {
                        ld.Errorf(s, "reloc %d to non-macho symbol %s type=%d", r.Type, rs.Name, rs.Type)
                        return -1
@@ -456,6 +456,9 @@ func machoreloc1(s *ld.Symbol, r *ld.Reloc, sectoff int64) int {
        case obj.R_PCREL:
                v |= 1 << 24 // pc-relative bit
                v |= ld.MACHO_X86_64_RELOC_SIGNED << 28
+       case obj.R_GOTPCREL:
+               v |= 1 << 24 // pc-relative bit
+               v |= ld.MACHO_X86_64_RELOC_GOT_LOAD << 28
        }
 
        switch r.Siz {