diff options
author | Cherry Zhang <cherryyz@google.com> | 2020-04-25 17:50:48 -0400 |
---|---|---|
committer | Cherry Zhang <cherryyz@google.com> | 2020-04-28 19:32:45 +0000 |
commit | 1adae7fe76d27cb9623cb269bb3ede2372f5eea6 (patch) | |
tree | bf01a2e4692817ed5fc5b846dee0340ac1cac277 /src/cmd/link/internal/loader/loader.go | |
parent | 0722a49b3713fe41bb46e7f690a3f7f1314edbc7 (diff) | |
download | go-1adae7fe76d27cb9623cb269bb3ede2372f5eea6.tar.gz go-1adae7fe76d27cb9623cb269bb3ede2372f5eea6.zip |
[dev.link] cmd/link: convert asmb pass to new style
Change-Id: I8675f56a7f7f18653754eb87b95f5a7aec31ad74
Reviewed-on: https://go-review.googlesource.com/c/go/+/229860
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Diffstat (limited to 'src/cmd/link/internal/loader/loader.go')
-rw-r--r-- | src/cmd/link/internal/loader/loader.go | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/src/cmd/link/internal/loader/loader.go b/src/cmd/link/internal/loader/loader.go index fb792ac059..775a2cb522 100644 --- a/src/cmd/link/internal/loader/loader.go +++ b/src/cmd/link/internal/loader/loader.go @@ -216,6 +216,8 @@ type Loader struct { sects []*sym.Section // sections symSects []uint16 // symbol's section, index to sects array + outdata [][]byte // symbol's data in the output buffer + itablink map[Sym]struct{} // itablink[j] defined if j is go.itablink.* objByPkg map[string]*oReader // map package path to its Go object reader @@ -1080,6 +1082,32 @@ func (l *Loader) Data(i Sym) []byte { return r.Data(li) } +// Returns the data of the i-th symbol in the output buffer. +func (l *Loader) OutData(i Sym) []byte { + if int(i) < len(l.outdata) && l.outdata[i] != nil { + return l.outdata[i] + } + return l.Data(i) +} + +// SetOutData sets the position of the data of the i-th symbol in the output buffer. +// i is global index. +func (l *Loader) SetOutData(i Sym, data []byte) { + if l.IsExternal(i) { + pp := l.getPayload(i) + if pp != nil { + pp.data = data + return + } + } + l.outdata[i] = data +} + +// InitOutData initializes the slice used to store symbol output data. +func (l *Loader) InitOutData() { + l.outdata = make([][]byte, l.extStart) +} + // SymAlign returns the alignment for a symbol. func (l *Loader) SymAlign(i Sym) int32 { // If an alignment has been recorded, return that. @@ -2592,8 +2620,7 @@ func loadObjFull(l *Loader, r *oReader) { size := osym.Siz() // Symbol data - s.P = r.Data(i) - s.Attr.Set(sym.AttrReadOnly, r.ReadOnly()) + s.P = l.OutData(gi) // Relocs relocs := l.relocs(r, i) |