cmd/link: convert symbol Add* functions to methods

Also reduce the passed context from *Link to *sys.Arch, so fewer
data dependencies need to be wired through all the code dealing
with symbols.

For #22095

Change-Id: I50969405d6562c5152bd1a3c443b72413e9b70bc
Reviewed-on: https://go-review.googlesource.com/67313
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
David Crawshaw 2017-09-30 15:06:44 +00:00
parent 2e405bde03
commit 0346664421
17 changed files with 752 additions and 739 deletions

View file

@ -359,11 +359,11 @@ func (ctxt *Link) loadlib() {
case BuildmodeCShared, BuildmodePlugin:
s := ctxt.Syms.Lookup("runtime.islibrary", 0)
s.Attr |= AttrDuplicateOK
Adduint8(ctxt, s, 1)
s.AddUint8(1)
case BuildmodeCArchive:
s := ctxt.Syms.Lookup("runtime.isarchive", 0)
s.Attr |= AttrDuplicateOK
Adduint8(ctxt, s, 1)
s.AddUint8(1)
}
loadinternal(ctxt, "runtime")
@ -485,14 +485,14 @@ func (ctxt *Link) loadlib() {
s := ctxt.Syms.Lookup("runtime.goarm", 0)
s.Type = SRODATA
s.Size = 0
Adduint8(ctxt, s, uint8(objabi.GOARM))
s.AddUint8(uint8(objabi.GOARM))
}
if objabi.Framepointer_enabled(objabi.GOOS, objabi.GOARCH) {
s := ctxt.Syms.Lookup("runtime.framepointer_enabled", 0)
s.Type = SRODATA
s.Size = 0
Adduint8(ctxt, s, 1)
s.AddUint8(1)
}
} else {
// If OTOH the module does not contain the runtime package,