mirror of https://github.com/golang/go.git
[dev.link] cmd/internal/goobj: use new style accessors
We already move to new style accessors in the linker. This will allow us to get rid of the read side of old style ones. Change-Id: Id0c171c5634a5977fe8a6f764cb0d48203993ab7 Reviewed-on: https://go-review.googlesource.com/c/go/+/226799 Reviewed-by: Jeremy Faller <jeremy@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
This commit is contained in:
parent
6dab0942a4
commit
a4129a1d20
|
|
@ -57,9 +57,8 @@ func (r *objReader) readNew() {
|
|||
pkg := pkglist[p]
|
||||
return SymID{fmt.Sprintf("%s.<#%d>", pkg, s.SymIdx), 0}
|
||||
}
|
||||
sym := goobj2.Sym{}
|
||||
sym.Read(rr, rr.SymOff(i))
|
||||
return SymID{sym.Name, abiToVer(sym.ABI)}
|
||||
sym := rr.Sym2(i)
|
||||
return SymID{sym.Name(rr), abiToVer(sym.ABI())}
|
||||
}
|
||||
|
||||
// Read things for the current goobj API for now.
|
||||
|
|
@ -69,16 +68,15 @@ func (r *objReader) readNew() {
|
|||
n := rr.NSym() + rr.NNonpkgdef() + rr.NNonpkgref()
|
||||
ndef := rr.NSym() + rr.NNonpkgdef()
|
||||
for i := 0; i < n; i++ {
|
||||
osym := goobj2.Sym{}
|
||||
osym.Read(rr, rr.SymOff(i))
|
||||
if osym.Name == "" {
|
||||
osym := rr.Sym2(i)
|
||||
if osym.Name(rr) == "" {
|
||||
continue // not a real symbol
|
||||
}
|
||||
// In a symbol name in an object file, "". denotes the
|
||||
// prefix for the package in which the object file has been found.
|
||||
// Expand it.
|
||||
name := strings.ReplaceAll(osym.Name, `"".`, r.pkgprefix)
|
||||
symID := SymID{Name: name, Version: abiToVer(osym.ABI)}
|
||||
name := strings.ReplaceAll(osym.Name(rr), `"".`, r.pkgprefix)
|
||||
symID := SymID{Name: name, Version: abiToVer(osym.ABI())}
|
||||
r.p.SymRefs = append(r.p.SymRefs, symID)
|
||||
|
||||
if i >= ndef {
|
||||
|
|
@ -91,45 +89,43 @@ func (r *objReader) readNew() {
|
|||
|
||||
sym := Sym{
|
||||
SymID: symID,
|
||||
Kind: objabi.SymKind(osym.Type),
|
||||
Kind: objabi.SymKind(osym.Type()),
|
||||
DupOK: osym.Dupok(),
|
||||
Size: int64(osym.Siz),
|
||||
Size: int64(osym.Siz()),
|
||||
Data: Data{int64(start + dataOff), siz},
|
||||
}
|
||||
r.p.Syms = append(r.p.Syms, &sym)
|
||||
|
||||
// Reloc
|
||||
nreloc := rr.NReloc(i)
|
||||
sym.Reloc = make([]Reloc, nreloc)
|
||||
for j := 0; j < nreloc; j++ {
|
||||
rel := goobj2.Reloc{}
|
||||
rel.Read(rr, rr.RelocOff(i, j))
|
||||
relocs := rr.Relocs2(i)
|
||||
sym.Reloc = make([]Reloc, len(relocs))
|
||||
for j := range relocs {
|
||||
rel := &relocs[j]
|
||||
sym.Reloc[j] = Reloc{
|
||||
Offset: int64(rel.Off),
|
||||
Size: int64(rel.Siz),
|
||||
Type: objabi.RelocType(rel.Type),
|
||||
Add: rel.Add,
|
||||
Sym: resolveSymRef(rel.Sym),
|
||||
Offset: int64(rel.Off()),
|
||||
Size: int64(rel.Siz()),
|
||||
Type: objabi.RelocType(rel.Type()),
|
||||
Add: rel.Add(),
|
||||
Sym: resolveSymRef(rel.Sym()),
|
||||
}
|
||||
}
|
||||
|
||||
// Aux symbol info
|
||||
isym := -1
|
||||
funcdata := make([]goobj2.SymRef, 0, 4)
|
||||
naux := rr.NAux(i)
|
||||
for j := 0; j < naux; j++ {
|
||||
a := goobj2.Aux{}
|
||||
a.Read(rr, rr.AuxOff(i, j))
|
||||
switch a.Type {
|
||||
auxs := rr.Auxs2(i)
|
||||
for j := range auxs {
|
||||
a := &auxs[j]
|
||||
switch a.Type() {
|
||||
case goobj2.AuxGotype:
|
||||
sym.Type = resolveSymRef(a.Sym)
|
||||
sym.Type = resolveSymRef(a.Sym())
|
||||
case goobj2.AuxFuncInfo:
|
||||
if a.Sym.PkgIdx != goobj2.PkgIdxSelf {
|
||||
if a.Sym().PkgIdx != goobj2.PkgIdxSelf {
|
||||
panic("funcinfo symbol not defined in current package")
|
||||
}
|
||||
isym = int(a.Sym.SymIdx)
|
||||
isym = int(a.Sym().SymIdx)
|
||||
case goobj2.AuxFuncdata:
|
||||
funcdata = append(funcdata, a.Sym)
|
||||
funcdata = append(funcdata, a.Sym())
|
||||
case goobj2.AuxDwarfInfo, goobj2.AuxDwarfLoc, goobj2.AuxDwarfRanges, goobj2.AuxDwarfLines:
|
||||
// nothing to do
|
||||
default:
|
||||
|
|
|
|||
Loading…
Reference in New Issue