Skip to content

Commit

Permalink
cmd/link: remove reading/processing of function Autom records
Browse files Browse the repository at this point in the history
Remove linker reading and processing of automs (no longer needed, now
that the compiler is emitting R_USETYPE relocations on functions). So
as to avoid changing the object file format, the object still contains
a count of automs, but this count is required to be zero.

Updates #34554.

Change-Id: I10230e191057c5c5705541eeb06f747d5f73c42d
Reviewed-on: https://go-review.googlesource.com/c/go/+/197500
Reviewed-by: Jeremy Faller <jeremy@golang.org>
  • Loading branch information
thanm committed Sep 27, 2019
1 parent cdd5920 commit 70a1efb
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 67 deletions.
6 changes: 0 additions & 6 deletions src/cmd/link/internal/ld/deadcode.go
Expand Up @@ -270,12 +270,6 @@ func (d *deadcodepass) flood() {
if d.ctxt.Debugvlog > 1 {
d.ctxt.Logf("marktext %s\n", s.Name)
}
if s.FuncInfo != nil {
for _, a := range s.FuncInfo.Autom {
d.mark(a.Gotype, s)
}
}

}

if strings.HasPrefix(s.Name, "type.") && s.Name[5] != '.' {
Expand Down
34 changes: 0 additions & 34 deletions src/cmd/link/internal/ld/lib.go
Expand Up @@ -2366,7 +2366,6 @@ func genasmsym(ctxt *Link, put func(*Link, *sym.Symbol, string, SymbolType, int6
}
}

var off int32
for _, s := range ctxt.Textp {
put(ctxt, s, s.Name, TextSym, s.Value, s.Gotype)

Expand All @@ -2380,39 +2379,6 @@ func genasmsym(ctxt *Link, put func(*Link, *sym.Symbol, string, SymbolType, int6
if s.FuncInfo == nil {
continue
}
for _, a := range s.FuncInfo.Autom {
if a.Name == objabi.A_DELETED_AUTO {
put(ctxt, nil, "", DeletedAutoSym, 0, a.Gotype)
continue
}

// Emit a or p according to actual offset, even if label is wrong.
// This avoids negative offsets, which cannot be encoded.
if a.Name != objabi.A_AUTO && a.Name != objabi.A_PARAM {
continue
}

// compute offset relative to FP
if a.Name == objabi.A_PARAM {
off = a.Aoffset
} else {
off = a.Aoffset - int32(ctxt.Arch.PtrSize)
}

// FP
if off >= 0 {
put(ctxt, nil, a.Asym.Name, ParamSym, int64(off), a.Gotype)
continue
}

// SP
if off <= int32(-ctxt.Arch.PtrSize) {
put(ctxt, nil, a.Asym.Name, AutoSym, -(int64(off) + int64(ctxt.Arch.PtrSize)), a.Gotype)
continue
}
// Otherwise, off is addressing the saved program counter.
// Something underhanded is going on. Say nothing.
}
}

if ctxt.Debugvlog != 0 || *flagN {
Expand Down
22 changes: 3 additions & 19 deletions src/cmd/link/internal/objfile/objfile.go
Expand Up @@ -55,7 +55,6 @@ type objReader struct {
data []byte
reloc []sym.Reloc
pcdata []sym.Pcdata
autom []sym.Auto
funcdata []*sym.Symbol
funcdataoff []int64
file []*sym.Symbol
Expand Down Expand Up @@ -193,8 +192,7 @@ func (r *objReader) readSlices() {
r.reloc = make([]sym.Reloc, n)
n = r.readInt()
r.pcdata = make([]sym.Pcdata, n)
n = r.readInt()
r.autom = make([]sym.Auto, n)
_ = r.readInt() // TODO: remove on next object file rev (autom count)
n = r.readInt()
r.funcdata = make([]*sym.Symbol, n)
r.funcdataoff = make([]int64, n)
Expand Down Expand Up @@ -328,24 +326,10 @@ overwrite:
s.Attr |= sym.AttrTopFrame
}
n := r.readInt()
pc.Autom = r.autom[:n:n]
if !isdup {
r.autom = r.autom[n:]
if n != 0 {
log.Fatalf("stale object file: autom count nonzero")
}

for i := 0; i < n; i++ {
pc.Autom[i] = sym.Auto{
Asym: r.readSymIndex(),
Aoffset: r.readInt32(),
Name: r.readInt16(),
Gotype: r.readSymIndex(),
}
}

// Temporary: zero out the autom list after we've read it.
// In a subsequent patch we'll remove autom handling more completely.
pc.Autom = nil

pc.Pcsp.P = r.readData()
pc.Pcfile.P = r.readData()
pc.Pcline.P = r.readData()
Expand Down
8 changes: 0 additions & 8 deletions src/cmd/link/internal/sym/symbol.go
Expand Up @@ -518,7 +518,6 @@ func SortSub(l *Symbol) *Symbol {
type FuncInfo struct {
Args int32
Locals int32
Autom []Auto
Pcsp Pcdata
Pcfile Pcdata
Pcline Pcdata
Expand All @@ -542,10 +541,3 @@ type InlinedCall struct {
type Pcdata struct {
P []byte
}

type Auto struct {
Asym *Symbol
Gotype *Symbol
Aoffset int32
Name int16
}

0 comments on commit 70a1efb

Please sign in to comment.