mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
[dev.link] cmd/link/internal/loader: add Loader plt/got access methods
Add accessor methods to get at the symbol {plt,got} value for
PE symbols. Fix a bug in the loaders SetPlt/SetGot methods.
Change-Id: I975bd6b86122622b206487c8798f8290ecd25a57
Reviewed-on: https://go-review.googlesource.com/c/go/+/225199
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
This commit is contained in:
parent
a9fb2e5155
commit
912e64ba46
1 changed files with 20 additions and 4 deletions
|
|
@ -1133,24 +1133,40 @@ func (l *Loader) SetSymElfType(i Sym, et elf.SymType) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SymPlt returns the plt value for pe symbols.
|
||||||
|
func (l *Loader) SymPlt(s Sym) int32 {
|
||||||
|
if v, ok := l.plt[s]; ok {
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
|
||||||
// SetPlt sets the plt value for pe symbols.
|
// SetPlt sets the plt value for pe symbols.
|
||||||
func (l *Loader) SetPlt(i Sym, v int32) {
|
func (l *Loader) SetPlt(i Sym, v int32) {
|
||||||
if i >= Sym(len(l.objSyms)) || i == 0 {
|
if i >= Sym(len(l.objSyms)) || i == 0 {
|
||||||
panic("bad symbol for SetPlt")
|
panic("bad symbol for SetPlt")
|
||||||
}
|
}
|
||||||
if v == 0 {
|
if v == -1 {
|
||||||
delete(l.plt, i)
|
delete(l.plt, i)
|
||||||
} else {
|
} else {
|
||||||
l.plt[i] = v
|
l.plt[i] = v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SymGot returns the got value for pe symbols.
|
||||||
|
func (l *Loader) SymGot(s Sym) int32 {
|
||||||
|
if v, ok := l.got[s]; ok {
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
|
||||||
// SetGot sets the got value for pe symbols.
|
// SetGot sets the got value for pe symbols.
|
||||||
func (l *Loader) SetGot(i Sym, v int32) {
|
func (l *Loader) SetGot(i Sym, v int32) {
|
||||||
if i >= Sym(len(l.objSyms)) || i == 0 {
|
if i >= Sym(len(l.objSyms)) || i == 0 {
|
||||||
panic("bad symbol for SetGot")
|
panic("bad symbol for SetGot")
|
||||||
}
|
}
|
||||||
if v == 0 {
|
if v == -1 {
|
||||||
delete(l.got, i)
|
delete(l.got, i)
|
||||||
} else {
|
} else {
|
||||||
l.got[i] = v
|
l.got[i] = v
|
||||||
|
|
@ -1257,11 +1273,11 @@ func (l *Loader) SymLocalentry(i Sym) uint8 {
|
||||||
return l.localentry[i]
|
return l.localentry[i]
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetSymExtname sets the "extname" attribute for a symbol.
|
// SetSymLocalentry sets the "local entry" attribute for a symbol.
|
||||||
func (l *Loader) SetSymLocalentry(i Sym, value uint8) {
|
func (l *Loader) SetSymLocalentry(i Sym, value uint8) {
|
||||||
// reject bad symbols
|
// reject bad symbols
|
||||||
if i >= Sym(len(l.objSyms)) || i == 0 {
|
if i >= Sym(len(l.objSyms)) || i == 0 {
|
||||||
panic("bad symbol index in SetExtname")
|
panic("bad symbol index in SetSymLocalentry")
|
||||||
}
|
}
|
||||||
if value == 0 {
|
if value == 0 {
|
||||||
delete(l.localentry, i)
|
delete(l.localentry, i)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue