]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.link] cmd/link: stream external relocations on 386 ELF
authorCherry Zhang <cherryyz@google.com>
Fri, 17 Jul 2020 21:05:22 +0000 (17:05 -0400)
committerCherry Zhang <cherryyz@google.com>
Tue, 21 Jul 2020 21:14:28 +0000 (21:14 +0000)
Change-Id: I17ff3ac82c8ac313f3a3c8e8129800ec9c05b991
Reviewed-on: https://go-review.googlesource.com/c/go/+/243643
Reviewed-by: Jeremy Faller <jeremy@golang.org>
src/cmd/link/internal/ld/asmb.go
src/cmd/link/internal/ld/data.go
src/cmd/link/internal/ld/elf.go
src/cmd/link/internal/ld/target.go

index a7b3237b3ee46c22c4b69137018358bb71da1c7c..f3e898bec533ad040050ce585fb7413726072293 100644 (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()
        }
 
index 8a21f55862b00eda9b91dbfc0e36dca93fc344da..d5034ae01cf8344d9817eb0ec6a9a18ddbb96196 100644 (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
index 2ba618ed0bf557ebc7c00fd5648d28e5cd7a3c1f..6a531cb333afd61e8445cd1c1552825ba5b26992 100644 (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)
index 102b6c543607b9ed38ca3896ec03d7fb6a4f019f..8702db121e52ed2f4d19c7ea534d28100ae1ece3 100644 (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())
+}