aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/link/internal/loader/loader.go
diff options
context:
space:
mode:
authorCherry Mui <cherryyz@google.com>2021-09-28 17:07:01 -0400
committerCherry Mui <cherryyz@google.com>2021-09-29 13:53:55 +0000
commite180e2c27c3c3f06a4df6352386efedc15a1e38c (patch)
treeb9a2addb3a2cfcea01926f97c1b21cde88fe06ff /src/cmd/link/internal/loader/loader.go
parent587b3c1192397393afb0ec5acd608e3dfe9f2116 (diff)
downloadgo-e180e2c27c3c3f06a4df6352386efedc15a1e38c.tar.xz
cmd/internal/goobj, cmd/link: remove funcdataoff
FUNCDATA is always a symbol reference with 0 offset. Assert the offset is 0 and remove funcdataoff. Change-Id: I326815365c9db5aeef6b869df5d78a9957bc16a6 Reviewed-on: https://go-review.googlesource.com/c/go/+/352894 Trust: Cherry Mui <cherryyz@google.com> 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.go62
1 files changed, 28 insertions, 34 deletions
diff --git a/src/cmd/link/internal/loader/loader.go b/src/cmd/link/internal/loader/loader.go
index ec145da26d..9b7888e940 100644
--- a/src/cmd/link/internal/loader/loader.go
+++ b/src/cmd/link/internal/loader/loader.go
@@ -1930,12 +1930,38 @@ func (l *Loader) NumPcdata(i Sym) int {
return n
}
+// Returns all funcdata symbols of symbol i.
+// tmp is a scratch space.
+func (l *Loader) Funcdata(i Sym, tmp []Sym) []Sym {
+ fd := tmp[:0]
+ r, auxs := l.auxs(i)
+ for j := range auxs {
+ a := &auxs[j]
+ if a.Type() == goobj.AuxFuncdata {
+ fd = append(fd, l.resolve(r, a.Sym()))
+ }
+ }
+ return fd
+}
+
+// Returns the number of funcdata for symbol i.
+func (l *Loader) NumFuncdata(i Sym) int {
+ n := 0
+ _, auxs := l.auxs(i)
+ for j := range auxs {
+ a := &auxs[j]
+ if a.Type() == goobj.AuxFuncdata {
+ n++
+ }
+ }
+ return n
+}
+
// FuncInfo provides hooks to access goobj.FuncInfo in the objects.
type FuncInfo struct {
l *Loader
r *oReader
data []byte
- auxs []goobj.Aux
lengths goobj.FuncInfoLengths
}
@@ -1963,38 +1989,6 @@ func (fi *FuncInfo) Preload() {
fi.lengths = (*goobj.FuncInfo)(nil).ReadFuncInfoLengths(fi.data)
}
-func (fi *FuncInfo) NumFuncdataoff() uint32 {
- if !fi.lengths.Initialized {
- panic("need to call Preload first")
- }
- return fi.lengths.NumFuncdataoff
-}
-
-func (fi *FuncInfo) Funcdataoff(k int) int64 {
- if !fi.lengths.Initialized {
- panic("need to call Preload first")
- }
- return (*goobj.FuncInfo)(nil).ReadFuncdataoff(fi.data, fi.lengths.FuncdataoffOff, uint32(k))
-}
-
-func (fi *FuncInfo) Funcdata(syms []Sym) []Sym {
- if !fi.lengths.Initialized {
- panic("need to call Preload first")
- }
- if int(fi.lengths.NumFuncdataoff) > cap(syms) {
- syms = make([]Sym, 0, fi.lengths.NumFuncdataoff)
- } else {
- syms = syms[:0]
- }
- for j := range fi.auxs {
- a := &fi.auxs[j]
- if a.Type() == goobj.AuxFuncdata {
- syms = append(syms, fi.l.resolve(fi.r, a.Sym()))
- }
- }
- return syms
-}
-
func (fi *FuncInfo) NumFile() uint32 {
if !fi.lengths.Initialized {
panic("need to call Preload first")
@@ -2051,7 +2045,7 @@ func (l *Loader) FuncInfo(i Sym) FuncInfo {
a := &auxs[j]
if a.Type() == goobj.AuxFuncInfo {
b := r.Data(a.Sym().SymIdx)
- return FuncInfo{l, r, b, auxs, goobj.FuncInfoLengths{}}
+ return FuncInfo{l, r, b, goobj.FuncInfoLengths{}}
}
}
return FuncInfo{}