[dev.link] cmd/internal/goobj2, cmd/link: experiment another way of accessing relocations

Use a different mechanism to access relocations from the object
files, and use it in the stack bounds check pass. This shows some
speedup.

(linking cmd/compile)
Dostkcheck     76.9ms ± 1%    55.1ms ± 1%  -28.36%  (p=0.008 n=5+5)

Change-Id: I2ac42da515dccd64719fb557ffff6cdc69e4319b
Reviewed-on: https://go-review.googlesource.com/c/go/+/222240
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
This commit is contained in:
Cherry Zhang 2020-03-05 11:29:24 -05:00
parent ad92148058
commit c951514da9
4 changed files with 76 additions and 5 deletions

View file

@ -49,6 +49,17 @@ type Reloc struct {
Sym Sym // global index of symbol the reloc addresses
}
// Reloc2 holds a "handle" to access a relocation record from an
// object file.
type Reloc2 struct {
*goobj2.Reloc2
r *oReader
l *Loader
}
func (rel Reloc2) Type() objabi.RelocType { return objabi.RelocType(rel.Reloc2.Type()) }
func (rel Reloc2) Sym() Sym { return rel.l.resolve(rel.r, rel.Reloc2.Sym()) }
// oReader is a wrapper type of obj.Reader, along with some
// extra information.
// TODO: rename to objReader once the old one is gone?
@ -1435,6 +1446,16 @@ func (relocs *Relocs) At(j int) Reloc {
}
}
func (relocs *Relocs) At2(j int) Reloc2 {
if relocs.l.isExtReader(relocs.r) {
// TODO: implement this. How? Maybe we can construct the reloc
// data for external symbols in the same byte form as the one
// in the object file?
panic("not implemented")
}
return Reloc2{relocs.r.Reloc2(relocs.li, j), relocs.r, relocs.l}
}
// ReadAll method reads all relocations for a symbol into the
// specified slice. If the slice capacity is not large enough, a new
// larger slice will be allocated. Final slice is returned.