Commit 9f4a359f authored by Michael Hudson-Doyle's avatar Michael Hudson-Doyle

cmd/compile, cmd/link, cmd/newlink: remove support for weak symbols

They were only used for rtype.ptrToThis which David Crawshaw removed a couple
of weeks ago. Removes two traversals of Ctxt.Allsym from the linker but it
doesn't seem to make much difference to performance.

Change-Id: I5c305e0180186f643221d57822d301de4aa18827
Reviewed-on: https://go-review.googlesource.com/20287Reviewed-by: 's avatarBrad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 6bd63ca3
......@@ -425,8 +425,6 @@ var typepkg *Pkg // fake package for runtime type info (headers)
var typelinkpkg *Pkg // fake package for runtime type info (data)
var weaktypepkg *Pkg // weak references to runtime type info
var unsafepkg *Pkg // package unsafe
var trackpkg *Pkg // fake package for field tracking
......
......@@ -140,11 +140,6 @@ func Main() {
itabpkg.Name = "go.itab"
itabpkg.Prefix = "go.itab" // not go%2eitab
weaktypepkg = mkpkg("go.weak.type")
weaktypepkg.Name = "go.weak.type"
weaktypepkg.Prefix = "go.weak.type" // not go%2eweak%2etype
typelinkpkg = mkpkg("go.typelink")
typelinkpkg.Name = "go.typelink"
typelinkpkg.Prefix = "go.typelink" // not go%2etypelink
......
......@@ -844,15 +844,6 @@ func typename(t *Type) *Node {
return n
}
func weaktypesym(t *Type) *Sym {
p := Tconv(t, obj.FmtLeft)
s := Pkglookup(p, weaktypepkg)
//print("weaktypesym: %s -> %+S\n", p, s);
return s
}
// isreflexive reports whether t has a reflexive equality operator.
// That is, if x==x for all x of type t.
func isreflexive(t *Type) bool {
......
......@@ -373,9 +373,6 @@ func mark1(s *LSym, parent *LSym) {
if s == nil || s.Attr.Reachable() {
return
}
if strings.HasPrefix(s.Name, "go.weak.") {
return
}
s.Attr |= AttrReachable
s.Reachparent = parent
markQueue = append(markQueue, s)
......@@ -494,14 +491,6 @@ func deadcode() {
}
}
for _, s := range Ctxt.Allsym {
if strings.HasPrefix(s.Name, "go.weak.") {
s.Attr |= AttrSpecial // do not lay out in data segment
s.Attr |= AttrReachable
s.Attr |= AttrHidden
}
}
// record field tracking references
var buf bytes.Buffer
for _, s := range Ctxt.Allsym {
......@@ -532,26 +521,6 @@ func deadcode() {
addstrdata(tracksym, buf.String())
}
func doweak() {
// resolve weak references only if
// target symbol will be in binary anyway.
for _, s := range Ctxt.Allsym {
if strings.HasPrefix(s.Name, "go.weak.") {
t := Linkrlookup(Ctxt, s.Name[8:], int(s.Version))
if t != nil && t.Type != 0 && t.Attr.Reachable() {
s.Value = t.Value
s.Type = t.Type
s.Outer = t
} else {
s.Type = obj.SCONST
s.Value = 0
}
continue
}
}
}
func addexport() {
if HEADTYPE == obj.Hdarwin {
return
......
......@@ -216,7 +216,6 @@ func Ldmain() {
symtab()
dodata()
address()
doweak()
reloc()
Thearch.Asmb()
undef()
......
......@@ -42,8 +42,7 @@ var linkerDefined = map[string]bool{
// isAuto reports whether sym is an automatically-generated data or constant symbol.
func (p *Prog) isAuto(sym goobj.SymID) bool {
return strings.HasPrefix(sym.Name, "go.weak.") ||
strings.HasPrefix(sym.Name, "$f64.") ||
return strings.HasPrefix(sym.Name, "$f64.") ||
strings.HasPrefix(sym.Name, "$f32.") ||
linkerDefined[sym.Name]
}
......@@ -85,24 +84,6 @@ func (p *Prog) autoData() {
}
}
// autoConst defines the automatically generated constant symbols needed by p.
func (p *Prog) autoConst() {
for sym := range p.Missing {
switch {
case strings.HasPrefix(sym.Name, "go.weak."):
// weak symbol resolves to actual symbol if present, or else nil.
delete(p.Missing, sym)
targ := sym
targ.Name = sym.Name[len("go.weak."):]
var addr Addr
if s := p.Syms[targ]; s != nil {
addr = s.Addr
}
p.defineConst(sym.Name, addr)
}
}
}
// defineConst defines a new symbol with the given name and constant address.
func (p *Prog) defineConst(name string, addr Addr) {
sym := goobj.SymID{Name: name}
......
......@@ -22,7 +22,6 @@ import (
// identical 8-byte sequences.
var autoTests = []string{
"testdata/autosection.6",
"testdata/autoweak.6",
}
func TestAuto(t *testing.T) {
......
......@@ -149,7 +149,6 @@ func (p *Prog) link(w io.Writer, mainFile string) {
p.runtime()
p.autoData()
p.layout()
p.autoConst()
if p.NumError > 0 {
return
}
......
// Copyright 2014 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Test of go.weak symbols.
TEXT start(SB),7,$0
MOVQ $autotab(SB),AX
MOVQ $autoptr(SB),AX
RET
// go.weak.sym should resolve to sym, because sym is in the binary.
DATA autotab+0(SB)/8, $go·weak·sym(SB)
DATA autotab+8(SB)/8, $sym(SB)
// go.weak.missingsym should resolve to 0, because missingsym is not in the binary.
DATA autotab+16(SB)/8, $go·weak·missingsym(SB)
DATA autotab+24(SB)/8, $0
// go.weak.deadsym should resolve to 0, because deadsym is discarded during dead code removal
DATA autotab+32(SB)/8, $go·weak·deadsym(SB)
DATA autotab+40(SB)/8, $0
GLOBL autotab(SB), $48
GLOBL sym(SB), $1
GLOBL deadsym(SB), $1
GLOBL autoptr(SB), $0
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment