mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
[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>
This commit is contained in:
parent
0722a49b37
commit
1adae7fe76
4 changed files with 77 additions and 45 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue