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>
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) {