aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/internal/obj
diff options
context:
space:
mode:
authorMichael Hudson-Doyle <michael.hudson@canonical.com>2015-09-02 11:23:15 +1200
committerMichael Hudson-Doyle <michael.hudson@canonical.com>2015-10-08 00:21:30 +0000
commita5cb76243af54a6729f5668317fb87baa242b9cc (patch)
tree17fec3b0ed013e7d1ed2865c89195d0ade9c6cfd /src/cmd/internal/obj
parent1ef9b5a5b90e6ea4dd5d9495cfe0d3d24446ff22 (diff)
downloadgo-a5cb76243af54a6729f5668317fb87baa242b9cc.tar.xz
cmd/internal/obj, cmd/link, runtime: lots of TLS cleanup
It's particularly nice to get rid of the android special cases in the linker. Change-Id: I516363af7ce8a6b2f196fe49cb8887ac787a6dad Reviewed-on: https://go-review.googlesource.com/14197 Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/cmd/internal/obj')
-rw-r--r--src/cmd/internal/obj/arm/asm5.go17
-rw-r--r--src/cmd/internal/obj/arm/obj5.go18
-rw-r--r--src/cmd/internal/obj/arm64/asm7.go3
-rw-r--r--src/cmd/internal/obj/link.go26
-rw-r--r--src/cmd/internal/obj/mips/asm0.go3
-rw-r--r--src/cmd/internal/obj/ppc64/asm9.go3
-rw-r--r--src/cmd/internal/obj/x86/obj6.go4
7 files changed, 10 insertions, 64 deletions
diff --git a/src/cmd/internal/obj/arm/asm5.go b/src/cmd/internal/obj/arm/asm5.go
index c240e89d46..3bf4a31729 100644
--- a/src/cmd/internal/obj/arm/asm5.go
+++ b/src/cmd/internal/obj/arm/asm5.go
@@ -739,9 +739,6 @@ func span5(ctxt *obj.Link, cursym *obj.LSym) {
* code references to be relocated too, and then
* perhaps we'd be able to parallelize the span loop above.
*/
- if ctxt.Tlsg == nil {
- ctxt.Tlsg = obj.Linklookup(ctxt, "runtime.tlsg", 0)
- }
p = cursym.Text
ctxt.Autosize = int32(p.To.Offset + 4)
@@ -1646,19 +1643,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
rel.Sym = p.To.Sym
rel.Add = p.To.Offset
- // runtime.tlsg is special.
- // Its "address" is the offset from the TLS thread pointer
- // to the thread-local g and m pointers.
- // Emit a TLS relocation instead of a standard one if its
- // type is not explicitly set by runtime. This assumes that
- // all references to runtime.tlsg should be accompanied with
- // its type declaration if necessary.
- if rel.Sym == ctxt.Tlsg && ctxt.Tlsg.Type == 0 {
- rel.Type = obj.R_TLS
- if ctxt.Flag_shared != 0 {
- rel.Add += ctxt.Pc - p.Rel.Pc - 8 - int64(rel.Siz)
- }
- } else if ctxt.Flag_shared != 0 {
+ if ctxt.Flag_shared != 0 {
rel.Type = obj.R_PCREL
rel.Add += ctxt.Pc - p.Rel.Pc - 8
} else {
diff --git a/src/cmd/internal/obj/arm/obj5.go b/src/cmd/internal/obj/arm/obj5.go
index d9f587b087..00ab13ccc3 100644
--- a/src/cmd/internal/obj/arm/obj5.go
+++ b/src/cmd/internal/obj/arm/obj5.go
@@ -129,24 +129,6 @@ func progedit(ctxt *obj.Link, p *obj.Prog) {
p.From.Offset = 0
}
}
-
- if ctxt.Flag_shared != 0 {
- // Shared libraries use R_ARM_TLS_IE32 instead of
- // R_ARM_TLS_LE32, replacing the link time constant TLS offset in
- // runtime.tlsg with an address to a GOT entry containing the
- // offset. Rewrite $runtime.tlsg(SB) to runtime.tlsg(SB) to
- // compensate.
- if ctxt.Tlsg == nil {
- ctxt.Tlsg = obj.Linklookup(ctxt, "runtime.tlsg", 0)
- }
-
- if p.From.Type == obj.TYPE_ADDR && p.From.Name == obj.NAME_EXTERN && p.From.Sym == ctxt.Tlsg {
- p.From.Type = obj.TYPE_MEM
- }
- if p.To.Type == obj.TYPE_ADDR && p.To.Name == obj.NAME_EXTERN && p.To.Sym == ctxt.Tlsg {
- p.To.Type = obj.TYPE_MEM
- }
- }
}
// Prog.mark
diff --git a/src/cmd/internal/obj/arm64/asm7.go b/src/cmd/internal/obj/arm64/asm7.go
index 3a56018985..a78c37e87d 100644
--- a/src/cmd/internal/obj/arm64/asm7.go
+++ b/src/cmd/internal/obj/arm64/asm7.go
@@ -631,9 +631,6 @@ func span7(ctxt *obj.Link, cursym *obj.LSym) {
/*
* lay out the code, emitting code and data relocations.
*/
- if ctxt.Tlsg == nil {
- ctxt.Tlsg = obj.Linklookup(ctxt, "runtime.tlsg", 0)
- }
obj.Symgrow(ctxt, cursym, cursym.Size)
bp := cursym.P
psz := int32(0)
diff --git a/src/cmd/internal/obj/link.go b/src/cmd/internal/obj/link.go
index 4217d6b0cb..4d6f7d7bdb 100644
--- a/src/cmd/internal/obj/link.go
+++ b/src/cmd/internal/obj/link.go
@@ -414,23 +414,16 @@ const (
R_CALLPOWER
R_CONST
R_PCREL
- // R_TLS (only used on arm currently, and not on android and darwin where tlsg is
- // a regular variable) resolves to data needed to access the thread-local g. It is
- // interpreted differently depending on toolchain flags to implement either the
- // "local exec" or "inital exec" model for tls access.
- // TODO(mwhudson): change to use R_TLS_LE or R_TLS_IE as appropriate, not having
- // R_TLS do double duty.
- R_TLS
- // R_TLS_LE (only used on 386 and amd64 currently) resolves to the offset of the
- // thread-local g from the thread local base and is used to implement the "local
- // exec" model for tls access (r.Sym is not set by the compiler for this case but
- // is set to Tlsg in the linker when externally linking).
+ // R_TLS_LE, used on 386, amd64, and ARM, resolves to the offset of the
+ // thread-local symbol from the thread local base and is used to implement the
+ // "local exec" model for tls access (r.Sym is not set on intel platforms but is
+ // set to a TLS symbol -- runtime.tlsg -- in the linker when externally linking).
R_TLS_LE
- // R_TLS_IE (only used on 386 and amd64 currently) resolves to the PC-relative
- // offset to a GOT slot containing the offset the thread-local g from the thread
- // local base and is used to implemented the "initial exec" model for tls access
- // (r.Sym is not set by the compiler for this case but is set to Tlsg in the
- // linker when externally linking).
+ // R_TLS_IE, used 386, amd64, and ARM resolves to the PC-relative offset to a GOT
+ // slot containing the offset from the thread-local symbol from the thread local
+ // base and is used to implemented the "initial exec" model for tls access (r.Sym
+ // is not set on intel platforms but is set to a TLS symbol -- runtime.tlsg -- in
+ // the linker when externally linking).
R_TLS_IE
R_GOTOFF
R_PLT0
@@ -505,7 +498,6 @@ type Link struct {
Sym_divu *LSym
Sym_mod *LSym
Sym_modu *LSym
- Tlsg *LSym
Plan9privates *LSym
Curp *Prog
Printp *Prog
diff --git a/src/cmd/internal/obj/mips/asm0.go b/src/cmd/internal/obj/mips/asm0.go
index 2955a0023d..c7498ea5f3 100644
--- a/src/cmd/internal/obj/mips/asm0.go
+++ b/src/cmd/internal/obj/mips/asm0.go
@@ -504,9 +504,6 @@ func span9(ctxt *obj.Link, cursym *obj.LSym) {
/*
* lay out the code, emitting code and data relocations.
*/
- if ctxt.Tlsg == nil {
- ctxt.Tlsg = obj.Linklookup(ctxt, "runtime.tlsg", 0)
- }
obj.Symgrow(ctxt, cursym, cursym.Size)
diff --git a/src/cmd/internal/obj/ppc64/asm9.go b/src/cmd/internal/obj/ppc64/asm9.go
index 5a1ba9cff2..745da9ef0d 100644
--- a/src/cmd/internal/obj/ppc64/asm9.go
+++ b/src/cmd/internal/obj/ppc64/asm9.go
@@ -504,9 +504,6 @@ func span9(ctxt *obj.Link, cursym *obj.LSym) {
/*
* lay out the code, emitting code and data relocations.
*/
- if ctxt.Tlsg == nil {
- ctxt.Tlsg = obj.Linklookup(ctxt, "runtime.tlsg", 0)
- }
obj.Symgrow(ctxt, cursym, cursym.Size)
diff --git a/src/cmd/internal/obj/x86/obj6.go b/src/cmd/internal/obj/x86/obj6.go
index e221bdab82..8fbe865219 100644
--- a/src/cmd/internal/obj/x86/obj6.go
+++ b/src/cmd/internal/obj/x86/obj6.go
@@ -435,10 +435,6 @@ func nacladdr(ctxt *obj.Link, p *obj.Prog, a *obj.Addr) {
}
func preprocess(ctxt *obj.Link, cursym *obj.LSym) {
- if ctxt.Tlsg == nil {
- ctxt.Tlsg = obj.Linklookup(ctxt, "runtime.tlsg", 0)
- }
-
if ctxt.Headtype == obj.Hplan9 && ctxt.Plan9privates == nil {
ctxt.Plan9privates = obj.Linklookup(ctxt, "_privates", 0)
}