aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThan McIntosh <thanm@google.com>2020-03-18 14:32:17 -0400
committerThan McIntosh <thanm@google.com>2020-03-23 15:10:20 +0000
commit49099d21f5f130b2c42eb4dfdf4ebeb8464c174c (patch)
tree55f40297e39548e5ccdb30d3e0b7724a5e241874 /src
parent5ffa696ade90f22da1615be65e412a84ce883de0 (diff)
downloadgo-49099d21f5f130b2c42eb4dfdf4ebeb8464c174c.tar.xz
[dev.link] cmd/link: add loader.Loader apis for symbol dynamic id
Add SymDynid and SetSymDynid methods to the loader. This symbol property is currently backed by a map. Change-Id: Iaf86b1d8aaa775fa102fadea30394eb8a670e0e2 Reviewed-on: https://go-review.googlesource.com/c/go/+/224378 Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Jeremy Faller <jeremy@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
Diffstat (limited to 'src')
-rw-r--r--src/cmd/link/internal/loader/loader.go25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/cmd/link/internal/loader/loader.go b/src/cmd/link/internal/loader/loader.go
index a916c50f19..13c4e5843c 100644
--- a/src/cmd/link/internal/loader/loader.go
+++ b/src/cmd/link/internal/loader/loader.go
@@ -240,6 +240,7 @@ type Loader struct {
symFile map[Sym]string // stores file 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
// Used to implement field tracking; created during deadcode if
// field tracking is enabled. Reachparent[K] contains the index of
@@ -302,6 +303,7 @@ func NewLoader(flags uint32, elfsetstring elfsetstringFunc) *Loader {
symFile: make(map[Sym]string),
plt: make(map[Sym]int32),
got: make(map[Sym]int32),
+ dynid: make(map[Sym]int32),
attrTopFrame: make(map[Sym]struct{}),
attrSpecial: make(map[Sym]struct{}),
attrCgoExportDynamic: make(map[Sym]struct{}),
@@ -1127,7 +1129,7 @@ func (l *Loader) SetPlt(i Sym, v int32) {
// SetGot sets the got value for pe symbols.
func (l *Loader) SetGot(i Sym, v int32) {
if i >= Sym(len(l.objSyms)) || i == 0 {
- panic("bad symbol for SetPlt")
+ panic("bad symbol for SetGot")
}
if v == 0 {
delete(l.got, i)
@@ -1136,6 +1138,27 @@ func (l *Loader) SetGot(i Sym, v int32) {
}
}
+// SymDynid returns the "dynid" property for the specified symbol.
+func (l *Loader) SymDynid(i Sym) int32 {
+ if s, ok := l.dynid[i]; ok {
+ return s
+ }
+ return -1
+}
+
+// SetSymDynid sets the "dynid" property for a symbol.
+func (l *Loader) SetSymDynid(i Sym, val int32) {
+ // reject bad symbols
+ if i >= Sym(len(l.objSyms)) || i == 0 {
+ panic("bad symbol index in SetSymDynid")
+ }
+ if val == -1 {
+ delete(l.dynid, i)
+ } else {
+ l.dynid[i] = val
+ }
+}
+
// SymGoType returns the 'Gotype' property for a given symbol (set by
// the Go compiler for variable symbols). This version relies on
// reading aux symbols for the target sym -- it could be that a faster