aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/link/internal/loader
diff options
context:
space:
mode:
authorJeremy Faller <jeremy@golang.org>2020-07-16 16:18:49 -0400
committerJeremy Faller <jeremy@golang.org>2020-07-31 13:55:07 +0000
commit6ac9914383bc88d014cbc681dae758372e6ca823 (patch)
tree1f41b4cbe03c274902ad26b6e19d33edbb5d6803 /src/cmd/link/internal/loader
parent3067a8dc02f62c287a8ccd3fcf16bfdf4f687f5f (diff)
downloadgo-6ac9914383bc88d014cbc681dae758372e6ca823.tar.xz
[dev.link] create runtime.funcnametab
Move the function names out of runtime.pclntab_old, creating runtime.funcnametab. There is an unfortunate artifact in this change in that calculating the funcID still requires loading the name. Future work will likely pull this out and put it into the object file Funcs. ls -l cmd/compile (darwin): before: 18524016 after: 18519952 The difference in size can be attributed to alignment in pclntab_old. Change-Id: Ibcbb230d4632178f8fcd0667165f5335786381f8 Reviewed-on: https://go-review.googlesource.com/c/go/+/243223 Reviewed-by: Austin Clements <austin@google.com>
Diffstat (limited to 'src/cmd/link/internal/loader')
-rw-r--r--src/cmd/link/internal/loader/loader.go16
-rw-r--r--src/cmd/link/internal/loader/symbolbuilder.go10
2 files changed, 26 insertions, 0 deletions
diff --git a/src/cmd/link/internal/loader/loader.go b/src/cmd/link/internal/loader/loader.go
index 89dce53ce5..251bfa018b 100644
--- a/src/cmd/link/internal/loader/loader.go
+++ b/src/cmd/link/internal/loader/loader.go
@@ -709,6 +709,22 @@ func (l *Loader) NReachableSym() int {
return l.attrReachable.Count()
}
+// SymNameLen returns the length of the symbol name, trying hard not to load
+// the name.
+func (l *Loader) SymNameLen(i Sym) int {
+ // Not much we can do about external symbols.
+ if l.IsExternal(i) {
+ return len(l.SymName(i))
+ }
+ r, li := l.toLocal(i)
+ le := r.Sym(li).NameLen(r.Reader)
+ if !r.NeedNameExpansion() {
+ return le
+ }
+ // Just load the symbol name. We don't know how expanded it'll be.
+ return len(l.SymName(i))
+}
+
// Returns the raw (unpatched) name of the i-th symbol.
func (l *Loader) RawSymName(i Sym) string {
if l.IsExternal(i) {
diff --git a/src/cmd/link/internal/loader/symbolbuilder.go b/src/cmd/link/internal/loader/symbolbuilder.go
index 314111d5ea..d8b800f375 100644
--- a/src/cmd/link/internal/loader/symbolbuilder.go
+++ b/src/cmd/link/internal/loader/symbolbuilder.go
@@ -311,6 +311,16 @@ func (sb *SymbolBuilder) SetAddr(arch *sys.Arch, off int64, tgt Sym) int64 {
return sb.SetAddrPlus(arch, off, tgt, 0)
}
+func (sb *SymbolBuilder) AddStringAt(off int64, str string) int64 {
+ strLen := int64(len(str))
+ if off+strLen+1 > int64(len(sb.data)) {
+ panic("attempt to write past end of buffer")
+ }
+ copy(sb.data[off:off+strLen], str)
+ sb.data[off+strLen] = 0
+ return off + strLen + 1
+}
+
func (sb *SymbolBuilder) Addstring(str string) int64 {
if sb.kind == 0 {
sb.kind = sym.SNOPTRDATA