]> Cypherpunks.ru repositories - gostls13.git/commitdiff
cmd/link: type alias sym.LoaderSym and loader.Sym
authorMatthew Dempsky <mdempsky@google.com>
Fri, 1 Sep 2023 20:12:49 +0000 (13:12 -0700)
committerGopher Robot <gobot@golang.org>
Fri, 1 Sep 2023 20:39:56 +0000 (20:39 +0000)
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>

src/cmd/link/internal/ld/dwarf.go
src/cmd/link/internal/loader/loader.go
src/cmd/link/internal/sym/compilation_unit.go

index 36e11cc0d282682421eb1570c99626c6dcfe21ca..19db1b557333618e0668535d19ae5e4a35ec15b6 100644 (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)))
index 4d0b497d8ef07c9a3cfef9763bfa444f35f283a9..617c6ba65a7c5a2dd6018b5e9dcd56ba587e4a47 100644 (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.
index 3bad5bf3f4fb1b0ed648cfb42638d71ae701c6e0..3d6cc3cf93418dd76b2fc1ef2f73cc07fd083920 100644 (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,