]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.link] cmd/link: remove Sub field from sym.Symbol
authorThan McIntosh <thanm@google.com>
Tue, 28 Apr 2020 19:25:54 +0000 (15:25 -0400)
committerThan McIntosh <thanm@google.com>
Wed, 29 Apr 2020 15:05:14 +0000 (15:05 +0000)
Remove 'Sub' field from sym.Symbol, replacing uses (those downstream of
loadlibfull) with loader method calls.

NB: removing the Outer field will have to wait for now; it is accessed
in archreloc methods that don't have access to link ctxt or loader
currently.

Change-Id: I2abe5906fc169c64b2ab7d5ad213619bea5a17c7
Reviewed-on: https://go-review.googlesource.com/c/go/+/230617
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/cmd/link/internal/ld/elf.go
src/cmd/link/internal/ld/lib.go
src/cmd/link/internal/loader/loader.go
src/cmd/link/internal/sym/sizeof_test.go
src/cmd/link/internal/sym/symbol.go

index 3be3f991711ca376523ec8317d4677cf907f4574..83f100c12ba5be592e21862573effe02eb7f4552 100644 (file)
@@ -2026,7 +2026,7 @@ func Asmbelf(ctxt *Link, symo int64) {
                // sh.info is the index of first non-local symbol (number of local symbols)
                s := ctxt.Syms.Lookup(".dynsym", 0)
                i := uint32(0)
-               for sub := s; sub != nil; sub = sub.Sub {
+               for sub := s; sub != nil; sub = symSub(ctxt, sub) {
                        i++
                        if !sub.Attr.Local() {
                                break
index 51d81eb28dc59e399fc3c07f81419f83ca64603e..baccb8baaeaab3ed4eb36e9ba9ccae248a5af578 100644 (file)
@@ -2929,12 +2929,19 @@ func ElfSymForReloc(ctxt *Link, s *sym.Symbol) int32 {
        }
 }
 
+func symSub(ctxt *Link, s *sym.Symbol) *sym.Symbol {
+       if lsub := ctxt.loader.SubSym(loader.Sym(s.SymIdx)); lsub != 0 {
+               return ctxt.loader.Syms[lsub]
+       }
+       return nil
+}
+
 func (ctxt *Link) dumpsyms() {
        for _, s := range ctxt.loader.Syms {
                if s == nil {
                        continue
                }
-               fmt.Printf("%s %s reachable=%v onlist=%v outer=%v sub=%v\n", s, s.Type, s.Attr.Reachable(), s.Attr.OnList(), s.Outer, s.Sub)
+               fmt.Printf("%s %s reachable=%v onlist=%v outer=%v sub=%v\n", s, s.Type, s.Attr.Reachable(), s.Attr.OnList(), s.Outer, symSub(ctxt, s))
                for i := range s.R {
                        fmt.Println("\t", s.R[i].Type, s.R[i].Sym)
                }
index 2abd0e60e161c7a9defdf49cb5c55b4bded4cc95..4fcdc1a661feddf8c33cf90b07d2c54181dbb89a 100644 (file)
@@ -2544,13 +2544,10 @@ func (l *Loader) migrateAttributes(src Sym, dst *sym.Symbol) {
        dst.Attr.Set(sym.AttrCgoExportStatic, l.AttrCgoExportStatic(src))
        dst.Attr.Set(sym.AttrReadOnly, l.AttrReadOnly(src))
 
-       // Convert outer/sub relationships
+       // Convert outer relationship
        if outer, ok := l.outer[src]; ok {
                dst.Outer = l.Syms[outer]
        }
-       if sub, ok := l.sub[src]; ok {
-               dst.Sub = l.Syms[sub]
-       }
 
        // Set sub-symbol attribute. See the comment on the AttrSubSymbol
        // method for more on this, there is some tricky stuff here.
index 4cfca3b5a33bb48984f48cfe8651ff1b5260fa0c..f358ccee66becdabe7c4538aa54db5ad8611e915 100644 (file)
@@ -21,7 +21,7 @@ func TestSizeof(t *testing.T) {
                _32bit uintptr     // size on 32bit platforms
                _64bit uintptr     // size on 64bit platforms
        }{
-               {Symbol{}, 84, 136},
+               {Symbol{}, 80, 128},
        }
 
        for _, tt := range tests {
index 546798fdf492e78375cf835de6e4034a8fccc4c4..3c3717ff318980e35a068c7dfe851e44c335544b 100644 (file)
@@ -23,7 +23,6 @@ type Symbol struct {
        Align   int32
        Value   int64
        Size    int64
-       Sub     *Symbol
        Outer   *Symbol
        SymIdx  LoaderSym
        auxinfo *AuxSymbol