aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/link/internal/loader/loader.go
diff options
context:
space:
mode:
authorCherry Zhang <cherryyz@google.com>2020-04-06 20:56:34 -0400
committerCherry Zhang <cherryyz@google.com>2020-04-08 15:28:34 +0000
commit5072c166a11f053a63c501c527e267a20b5176e1 (patch)
treed4daf4df6f351016075c0a8c9f4e822f43d0bff3 /src/cmd/link/internal/loader/loader.go
parent95ea64ba96abbba204db3f905eec8c63257f425e (diff)
downloadgo-5072c166a11f053a63c501c527e267a20b5176e1.tar.gz
go-5072c166a11f053a63c501c527e267a20b5176e1.zip
[dev.link] cmd/link: return package path in SymFile
SymFile, derived from sym.Symbol.File, is supposed to return the package path, instead of the file name (arguably the name is confusing). Make it so, and rename it to SymPkg. Change-Id: I67bcd12f67cea271f2a2ce3c5724e5d228f5b2f0 Reviewed-on: https://go-review.googlesource.com/c/go/+/227481 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Jeremy Faller <jeremy@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
Diffstat (limited to 'src/cmd/link/internal/loader/loader.go')
-rw-r--r--src/cmd/link/internal/loader/loader.go40
1 files changed, 20 insertions, 20 deletions
diff --git a/src/cmd/link/internal/loader/loader.go b/src/cmd/link/internal/loader/loader.go
index acce23c0c2..32386ccbc0 100644
--- a/src/cmd/link/internal/loader/loader.go
+++ b/src/cmd/link/internal/loader/loader.go
@@ -243,7 +243,7 @@ type Loader struct {
localentry map[Sym]uint8 // stores Localentry symbol attribute
extname map[Sym]string // stores Extname symbol attribute
elfType map[Sym]elf.SymType // stores elf type symbol property
- symFile map[Sym]string // stores file for shlib-derived syms
+ symPkg map[Sym]string // stores package for symbol, or library for shlib-derived syms
plt map[Sym]int32 // stores dynimport for pe objects
got map[Sym]int32 // stores got for pe objects
dynid map[Sym]int32 // stores Dynid for symbol
@@ -311,7 +311,7 @@ func NewLoader(flags uint32, elfsetstring elfsetstringFunc) *Loader {
extname: make(map[Sym]string),
attrReadOnly: make(map[Sym]bool),
elfType: make(map[Sym]elf.SymType),
- symFile: make(map[Sym]string),
+ symPkg: make(map[Sym]string),
plt: make(map[Sym]int32),
got: make(map[Sym]int32),
dynid: make(map[Sym]int32),
@@ -1228,39 +1228,39 @@ func (l *Loader) SymUnit(i Sym) *sym.CompilationUnit {
return r.unit
}
-// SymFile returns the file for a symbol, which is normally the
-// package the symbol came from (for regular compiler-generated Go
-// symbols), but in the case of building with "-linkshared" (when a
-// symbol is read from a a shared library), will hold the library
-// name.
-func (l *Loader) SymFile(i Sym) string {
+// SymPkg returns the package where the symbol came from (for
+// regular compiler-generated Go symbols), but in the case of
+// building with "-linkshared" (when a symbol is read from a
+// shared library), will hold the library name.
+// NOTE: this correspondes to sym.Symbol.File field.
+func (l *Loader) SymPkg(i Sym) string {
if l.IsExternal(i) {
- if f, ok := l.symFile[i]; ok {
+ if f, ok := l.symPkg[i]; ok {
return f
}
pp := l.getPayload(i)
if pp.objidx != 0 {
r := l.objs[pp.objidx].r
- return r.unit.Lib.File
+ return r.unit.Lib.Pkg
}
return ""
}
r, _ := l.toLocal(i)
- return r.unit.Lib.File
+ return r.unit.Lib.Pkg
}
-// SetSymFile sets the file attribute for a symbol. This is
+// SetSymPkg sets the package/library for a symbol. This is
// needed mainly for external symbols, specifically those imported
// from shared libraries.
-func (l *Loader) SetSymFile(i Sym, file string) {
+func (l *Loader) SetSymPkg(i Sym, pkg string) {
// reject bad symbols
if i >= Sym(len(l.objSyms)) || i == 0 {
- panic("bad symbol index in SetSymFile")
+ panic("bad symbol index in SetSymPkg")
}
if !l.IsExternal(i) {
panic("can't set file for non-external sym")
}
- l.symFile[i] = file
+ l.symPkg[i] = pkg
}
// SymLocalentry returns the "local entry" value for the specified
@@ -1732,10 +1732,10 @@ func (l *Loader) LoadFull(arch *sys.Arch, syms *sym.Symbols) {
if pp.gotype != 0 {
s.Gotype = l.Syms[pp.gotype]
}
- if f, ok := l.symFile[i]; ok {
+ if f, ok := l.symPkg[i]; ok {
s.File = f
} else if pp.objidx != 0 {
- s.File = l.objs[pp.objidx].r.unit.Lib.File
+ s.File = l.objs[pp.objidx].r.unit.Lib.Pkg
}
// Copy relocations
@@ -1909,12 +1909,12 @@ func (l *Loader) PropagateLoaderChangesToSymbols(toconvert []Sym, anonVerReplace
if gt := l.SymGoType(cand); gt != 0 {
s.Gotype = l.Syms[gt]
}
- if f, ok := l.symFile[cand]; ok {
+ if f, ok := l.symPkg[cand]; ok {
s.File = f
} else {
r, _ := l.toLocal(cand)
if r != nil && r != l.extReader {
- s.File = l.SymFile(cand)
+ s.File = l.SymPkg(cand)
}
}
}
@@ -2191,7 +2191,7 @@ func (l *Loader) CopySym(src, dst Sym) {
panic("src is not external") //l.cloneToExternal(src)
}
l.payloads[l.extIndex(dst)] = l.payloads[l.extIndex(src)]
- l.SetSymFile(dst, l.SymFile(src))
+ l.SetSymPkg(dst, l.SymPkg(src))
// TODO: other attributes?
}