1
0
mirror of https://github.com/golang/go synced 2024-09-30 05:34:35 -06:00

[dev.link] cmd/link: stream external relocations on 386 ELF

Change-Id: I17ff3ac82c8ac313f3a3c8e8129800ec9c05b991
Reviewed-on: https://go-review.googlesource.com/c/go/+/243643
Reviewed-by: Jeremy Faller <jeremy@golang.org>
This commit is contained in:
Cherry Zhang 2020-07-17 17:05:22 -04:00
parent 0e3114871e
commit 936a2d6966
4 changed files with 10 additions and 5 deletions

View File

@ -19,7 +19,7 @@ import (
// This function handles the first part.
func asmb(ctxt *Link) {
ctxt.loader.InitOutData()
if ctxt.IsExternal() && !(ctxt.IsAMD64() && ctxt.IsELF) {
if ctxt.IsExternal() && !ctxt.StreamExtRelocs() {
ctxt.loader.InitExtRelocs()
}

View File

@ -159,7 +159,7 @@ func (st *relocSymState) relocsym(s loader.Sym, P []byte) {
target := st.target
syms := st.syms
var extRelocs []loader.ExtReloc
if target.IsExternal() && !(target.IsAMD64() && target.IsELF) {
if target.IsExternal() && !target.StreamExtRelocs() {
// preallocate a slice conservatively assuming that all
// relocs will require an external reloc
extRelocs = st.preallocExtRelocSlice(relocs.Count())
@ -592,14 +592,14 @@ func (st *relocSymState) relocsym(s loader.Sym, P []byte) {
addExtReloc:
if needExtReloc {
if target.IsAMD64() && target.IsELF {
if target.StreamExtRelocs() {
extraExtReloc++
} else {
extRelocs = append(extRelocs, rr)
}
}
}
if target.IsExternal() && target.IsAMD64() && target.IsELF {
if target.IsExternal() && target.StreamExtRelocs() {
// On AMD64 ELF, we'll stream out the external relocations in elfrelocsect
// and we only need the count here.
// TODO: just count, but not compute the external relocations. For now it

View File

@ -1372,7 +1372,7 @@ func elfrelocsect(ctxt *Link, out *OutBuf, sect *sym.Section, syms []loader.Sym)
break
}
if ctxt.IsAMD64() {
if ctxt.StreamExtRelocs() {
// Compute external relocations on the go, and pass to Elfreloc1
// to stream out.
relocs := ldr.Relocs(s)

View File

@ -181,3 +181,8 @@ func (t *Target) mustSetHeadType() {
func (t *Target) IsBigEndian() bool {
return t.Arch.ByteOrder == binary.BigEndian
}
// Temporary helper.
func (t *Target) StreamExtRelocs() bool {
return t.IsELF && (t.IsAMD64() || t.Is386())
}