1
0
mirror of https://github.com/golang/go synced 2024-11-18 19:54:44 -07:00

cmd/link: type alias sym.LoaderSym and loader.Sym

Rather than making these two different types, we can type alias them
together. This will ease converting cmd/internal/dwarf to use generics
in a subsequent CL.

The one unfortunate quirk is that while we'd currently like loader.Sym
to be the authoritative type, to break the cycle we have to instead
make loader.Sym an alias of sym.LoaderSym.

Change-Id: I6dde0d492ca89a478c2470c426bb4eed3393d680
Reviewed-on: https://go-review.googlesource.com/c/go/+/525195
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
Matthew Dempsky 2023-09-01 13:12:49 -07:00 committed by Gopher Robot
parent c9bb7ce2d7
commit 9b0140a695
3 changed files with 5 additions and 15 deletions

View File

@ -1513,16 +1513,6 @@ const (
COMPUNITHEADERSIZE = 4 + 2 + 4 + 1
)
// appendSyms appends the syms from 'src' into 'syms' and returns the
// result. This can go away once we do away with sym.LoaderSym
// entirely.
func appendSyms(syms []loader.Sym, src []sym.LoaderSym) []loader.Sym {
for _, s := range src {
syms = append(syms, loader.Sym(s))
}
return syms
}
func (d *dwctxt) writeUnitInfo(u *sym.CompilationUnit, abbrevsym loader.Sym, infoEpilog loader.Sym) []loader.Sym {
syms := []loader.Sym{}
if len(u.Textp) == 0 && u.DWInfo.Child == nil && len(u.VarDIEs) == 0 {
@ -1551,12 +1541,12 @@ func (d *dwctxt) writeUnitInfo(u *sym.CompilationUnit, abbrevsym loader.Sym, inf
// This is an under-estimate; more will be needed for type DIEs.
cu := make([]loader.Sym, 0, len(u.AbsFnDIEs)+len(u.FuncDIEs))
cu = append(cu, s)
cu = appendSyms(cu, u.AbsFnDIEs)
cu = appendSyms(cu, u.FuncDIEs)
cu = append(cu, u.AbsFnDIEs...)
cu = append(cu, u.FuncDIEs...)
if u.Consts != 0 {
cu = append(cu, loader.Sym(u.Consts))
}
cu = appendSyms(cu, u.VarDIEs)
cu = append(cu, u.VarDIEs...)
var cusize int64
for _, child := range cu {
cusize += int64(len(d.ldr.Data(child)))

View File

@ -27,7 +27,7 @@ var _ = fmt.Print
// Sym encapsulates a global symbol index, used to identify a specific
// Go symbol. The 0-valued Sym is corresponds to an invalid symbol.
type Sym uint32
type Sym = sym.LoaderSym
// Relocs encapsulates the set of relocations on a given symbol; an
// instance of this type is returned by the Loader Relocs() method.

View File

@ -8,7 +8,7 @@ import "cmd/internal/dwarf"
// LoaderSym holds a loader.Sym value. We can't refer to this
// type from the sym package since loader imports sym.
type LoaderSym int
type LoaderSym uint32
// A CompilationUnit represents a set of source files that are compiled
// together. Since all Go sources in a Go package are compiled together,