mirror of
https://github.com/golang/go
synced 2024-11-18 04:04:49 -07: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:
parent
0e3114871e
commit
936a2d6966
@ -19,7 +19,7 @@ import (
|
|||||||
// This function handles the first part.
|
// This function handles the first part.
|
||||||
func asmb(ctxt *Link) {
|
func asmb(ctxt *Link) {
|
||||||
ctxt.loader.InitOutData()
|
ctxt.loader.InitOutData()
|
||||||
if ctxt.IsExternal() && !(ctxt.IsAMD64() && ctxt.IsELF) {
|
if ctxt.IsExternal() && !ctxt.StreamExtRelocs() {
|
||||||
ctxt.loader.InitExtRelocs()
|
ctxt.loader.InitExtRelocs()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,7 +159,7 @@ func (st *relocSymState) relocsym(s loader.Sym, P []byte) {
|
|||||||
target := st.target
|
target := st.target
|
||||||
syms := st.syms
|
syms := st.syms
|
||||||
var extRelocs []loader.ExtReloc
|
var extRelocs []loader.ExtReloc
|
||||||
if target.IsExternal() && !(target.IsAMD64() && target.IsELF) {
|
if target.IsExternal() && !target.StreamExtRelocs() {
|
||||||
// preallocate a slice conservatively assuming that all
|
// preallocate a slice conservatively assuming that all
|
||||||
// relocs will require an external reloc
|
// relocs will require an external reloc
|
||||||
extRelocs = st.preallocExtRelocSlice(relocs.Count())
|
extRelocs = st.preallocExtRelocSlice(relocs.Count())
|
||||||
@ -592,14 +592,14 @@ func (st *relocSymState) relocsym(s loader.Sym, P []byte) {
|
|||||||
|
|
||||||
addExtReloc:
|
addExtReloc:
|
||||||
if needExtReloc {
|
if needExtReloc {
|
||||||
if target.IsAMD64() && target.IsELF {
|
if target.StreamExtRelocs() {
|
||||||
extraExtReloc++
|
extraExtReloc++
|
||||||
} else {
|
} else {
|
||||||
extRelocs = append(extRelocs, rr)
|
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
|
// On AMD64 ELF, we'll stream out the external relocations in elfrelocsect
|
||||||
// and we only need the count here.
|
// and we only need the count here.
|
||||||
// TODO: just count, but not compute the external relocations. For now it
|
// TODO: just count, but not compute the external relocations. For now it
|
||||||
|
@ -1372,7 +1372,7 @@ func elfrelocsect(ctxt *Link, out *OutBuf, sect *sym.Section, syms []loader.Sym)
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
if ctxt.IsAMD64() {
|
if ctxt.StreamExtRelocs() {
|
||||||
// Compute external relocations on the go, and pass to Elfreloc1
|
// Compute external relocations on the go, and pass to Elfreloc1
|
||||||
// to stream out.
|
// to stream out.
|
||||||
relocs := ldr.Relocs(s)
|
relocs := ldr.Relocs(s)
|
||||||
|
@ -181,3 +181,8 @@ func (t *Target) mustSetHeadType() {
|
|||||||
func (t *Target) IsBigEndian() bool {
|
func (t *Target) IsBigEndian() bool {
|
||||||
return t.Arch.ByteOrder == binary.BigEndian
|
return t.Arch.ByteOrder == binary.BigEndian
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Temporary helper.
|
||||||
|
func (t *Target) StreamExtRelocs() bool {
|
||||||
|
return t.IsELF && (t.IsAMD64() || t.Is386())
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user