]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.link] cmd/link: add SymVersion loader method
authorThan McIntosh <thanm@google.com>
Thu, 26 Dec 2019 18:39:04 +0000 (13:39 -0500)
committerThan McIntosh <thanm@google.com>
Fri, 27 Dec 2019 15:05:16 +0000 (15:05 +0000)
Add a loader method to retrieve the version from a loader.Sym
(useful mainly for debugging at the moment).

Change-Id: I82e0e316bb86eb41b9cf366e656a0f848cf3424e
Reviewed-on: https://go-review.googlesource.com/c/go/+/212617
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
src/cmd/link/internal/loader/loader.go

index f774c0c8dda4e22a394dd43774f28e3ea800fd4a..029e10fedaa9b6ac76251caadec4950012038468 100644 (file)
@@ -607,6 +607,21 @@ func (l *Loader) SymName(i Sym) string {
        return strings.Replace(osym.Name, "\"\".", r.pkgprefix, -1)
 }
 
+// Returns the version of the i-th symbol.
+func (l *Loader) SymVersion(i Sym) int {
+       if l.IsExternal(i) {
+               if s := l.Syms[i]; s != nil {
+                       return int(s.Version)
+               }
+               pp := l.getPayload(i)
+               return pp.ver
+       }
+       r, li := l.toLocal(i)
+       osym := goobj2.Sym{}
+       osym.Read(r.Reader, r.SymOff(li))
+       return int(abiToVer(osym.ABI, r.version))
+}
+
 // Returns the type of the i-th symbol.
 func (l *Loader) SymType(i Sym) sym.SymKind {
        if l.IsExternal(i) {