aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/internal/obj/objfile.go
diff options
context:
space:
mode:
authorCherry Mui <cherryyz@google.com>2021-09-27 15:35:46 -0400
committerCherry Mui <cherryyz@google.com>2021-09-28 15:25:40 +0000
commitdf63673d6a85d4243cc68c2225264afab6cfbf3b (patch)
tree274cb6078afc5b2796d7a65d3fc7ea5e729d0e66 /src/cmd/internal/obj/objfile.go
parent02d56a1584f968b86b669b3b943dc2ffad30e087 (diff)
downloadgo-df63673d6a85d4243cc68c2225264afab6cfbf3b.tar.xz
cmd/internal/obj: index pcdata symbols in NumberSyms
When writing an object file, most symbols are indexed in NumberSyms. Currently, pcdata symbols are indexed late and separately. This is not really necessary, as pcdata symbols already exist at the time of NumberSyms. Just do it there. As pcdata symbols are laid out in the pclntab in a special way at link time, distinguish them from other symbols in the content hash. (In the old code this was partly achieved by indexing them late.) Change-Id: Ie9e721382b0af2cfb39350d031e2e66d79095a3c Reviewed-on: https://go-review.googlesource.com/c/go/+/352611 Trust: Cherry Mui <cherryyz@google.com> Trust: Josh Bleecher Snyder <josharian@gmail.com> Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Diffstat (limited to 'src/cmd/internal/obj/objfile.go')
-rw-r--r--src/cmd/internal/obj/objfile.go24
1 files changed, 8 insertions, 16 deletions
diff --git a/src/cmd/internal/obj/objfile.go b/src/cmd/internal/obj/objfile.go
index 1a8a9635d6..030a02b499 100644
--- a/src/cmd/internal/obj/objfile.go
+++ b/src/cmd/internal/obj/objfile.go
@@ -391,7 +391,9 @@ func (w *writer) Hash(s *LSym) {
// TODO: instead of duplicating them, have the compiler decide where symbols go.
func contentHashSection(s *LSym) byte {
name := s.Name
- if strings.HasPrefix(name, "type.") {
+ if s.IsPcdata() {
+ return 'P'
+ } else if strings.HasPrefix(name, "type.") {
return 'T'
}
return 0
@@ -655,16 +657,6 @@ func nAuxSym(s *LSym) int {
func genFuncInfoSyms(ctxt *Link) {
infosyms := make([]*LSym, 0, len(ctxt.Text))
hashedsyms := make([]*LSym, 0, 4*len(ctxt.Text))
- preparePcSym := func(s *LSym) *LSym {
- if s == nil {
- return s
- }
- s.PkgIdx = goobj.PkgIdxHashed
- s.SymIdx = int32(len(hashedsyms) + len(ctxt.hasheddefs))
- s.Set(AttrIndexed, true)
- hashedsyms = append(hashedsyms, s)
- return s
- }
var b bytes.Buffer
symidx := int32(len(ctxt.defs))
for _, s := range ctxt.Text {
@@ -679,13 +671,13 @@ func genFuncInfoSyms(ctxt *Link) {
FuncFlag: fn.FuncFlag,
}
pc := &fn.Pcln
- o.Pcsp = makeSymRef(preparePcSym(pc.Pcsp))
- o.Pcfile = makeSymRef(preparePcSym(pc.Pcfile))
- o.Pcline = makeSymRef(preparePcSym(pc.Pcline))
- o.Pcinline = makeSymRef(preparePcSym(pc.Pcinline))
+ o.Pcsp = makeSymRef(pc.Pcsp)
+ o.Pcfile = makeSymRef(pc.Pcfile)
+ o.Pcline = makeSymRef(pc.Pcline)
+ o.Pcinline = makeSymRef(pc.Pcinline)
o.Pcdata = make([]goobj.SymRef, len(pc.Pcdata))
for i, pcSym := range pc.Pcdata {
- o.Pcdata[i] = makeSymRef(preparePcSym(pcSym))
+ o.Pcdata[i] = makeSymRef(pcSym)
}
o.Funcdataoff = make([]uint32, len(pc.Funcdataoff))
for i, x := range pc.Funcdataoff {