]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.link] cmd/link: simplify field tracking support
authorCherry Zhang <cherryyz@google.com>
Thu, 14 May 2020 17:15:53 +0000 (13:15 -0400)
committerCherry Zhang <cherryyz@google.com>
Thu, 14 May 2020 17:36:27 +0000 (17:36 +0000)
Currently, for the special field tracking symbol go.track.XXX,
when they are reachable, we set its type to SCONST. There is no
need to do that. Just leave it unset (as Sxxx). The symbol is
done after this point.

Change-Id: I966d80775008f7fb5d30fbc6b9e4a30ae8316b6c
Reviewed-on: https://go-review.googlesource.com/c/go/+/233998
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
src/cmd/link/internal/ld/data.go
src/cmd/link/internal/ld/go.go

index 7254d2b1722a163faa46d22846366e789a76922e..da96b368821c5378d442c8240232df9ae58c8f3e 100644 (file)
@@ -191,6 +191,9 @@ func (st *relocSymState) relocsym(s loader.Sym, P []byte) {
                        st.err.Errorf(s, "invalid relocation %s: %d+%d not in [%d,%d)", rname, off, siz, 0, len(P))
                        continue
                }
+               if siz == 0 { // informational relocation - no work to do
+                       continue
+               }
 
                var rst sym.SymKind
                if rs != 0 {
@@ -218,9 +221,6 @@ func (st *relocSymState) relocsym(s loader.Sym, P []byte) {
                if rt >= objabi.ElfRelocOffset {
                        continue
                }
-               if siz == 0 { // informational relocation - no work to do
-                       continue
-               }
 
                // We need to be able to reference dynimport symbols when linking against
                // shared libraries, and Solaris, Darwin and AIX need it always
index 9a63a3a0bb36863f2d2d60b60263c3f4b1d45a9f..c3c987dcae222e68bb60b4c13dabb2ca3b07a6e3 100644 (file)
@@ -351,19 +351,15 @@ func fieldtrack(arch *sys.Arch, l *loader.Loader) {
        var buf bytes.Buffer
        for i := loader.Sym(1); i < loader.Sym(l.NSym()); i++ {
                if name := l.SymName(i); strings.HasPrefix(name, "go.track.") {
-                       bld := l.MakeSymbolUpdater(i)
-                       bld.SetSpecial(true)
-                       bld.SetNotInSymbolTable(true)
-                       if bld.Reachable() {
+                       if l.AttrReachable(i) {
+                               l.SetAttrSpecial(i, true)
+                               l.SetAttrNotInSymbolTable(i, true)
                                buf.WriteString(name[9:])
                                for p := l.Reachparent[i]; p != 0; p = l.Reachparent[p] {
                                        buf.WriteString("\t")
                                        buf.WriteString(l.SymName(p))
                                }
                                buf.WriteString("\n")
-
-                               bld.SetType(sym.SCONST)
-                               bld.SetValue(0)
                        }
                }
        }