mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
[dev.link] cmd/link: convert symtab pass to new style
This is more or less a direct translation, to get things going. There are more things we can do to make it better, especially on the handling of container symbols. Change-Id: I11a0087e402be8d42b9d06869385ead531755272 Reviewed-on: https://go-review.googlesource.com/c/go/+/229125 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Jeremy Faller <jeremy@golang.org>
This commit is contained in:
parent
5cccd7a724
commit
47cac82e36
7 changed files with 292 additions and 248 deletions
|
|
@ -2627,6 +2627,16 @@ func (ctxt *Link) xdefine(p string, t sym.SymKind, v int64) {
|
|||
s.Attr |= sym.AttrLocal
|
||||
}
|
||||
|
||||
func (ctxt *Link) xdefine2(p string, t sym.SymKind, v int64) {
|
||||
ldr := ctxt.loader
|
||||
s := ldr.CreateSymForUpdate(p, 0)
|
||||
s.SetType(t)
|
||||
s.SetValue(v)
|
||||
s.SetReachable(true)
|
||||
s.SetSpecial(true)
|
||||
s.SetLocal(true)
|
||||
}
|
||||
|
||||
func datoff(s *sym.Symbol, addr int64) int64 {
|
||||
if uint64(addr) >= Segdata.Vaddr {
|
||||
return int64(uint64(addr) - Segdata.Vaddr + Segdata.Fileoff)
|
||||
|
|
@ -2816,10 +2826,6 @@ func (ctxt *Link) loadlibfull() {
|
|||
// Set special global symbols.
|
||||
ctxt.setArchSyms(AfterLoadlibFull)
|
||||
|
||||
// Convert special symbols created by pcln.
|
||||
pclntabFirstFunc = ctxt.loader.Syms[pclntabFirstFunc2]
|
||||
pclntabLastFunc = ctxt.loader.Syms[pclntabLastFunc2]
|
||||
|
||||
// Populate dwarfp from dwarfp2. If we see a symbol index
|
||||
// whose loader.Syms entry is nil, something went wrong.
|
||||
for _, si := range dwarfp2 {
|
||||
|
|
@ -2834,11 +2840,27 @@ func (ctxt *Link) loadlibfull() {
|
|||
}
|
||||
dwarfp = append(dwarfp, dwarfSecInfo2{syms: syms})
|
||||
}
|
||||
|
||||
// For now, overwrite symbol type with its "group" type, as dodata
|
||||
// expected. Once we converted dodata, this will probably not be
|
||||
// needed.
|
||||
for i, t := range symGroupType {
|
||||
if t != sym.Sxxx {
|
||||
ctxt.loader.Syms[i].Type = t
|
||||
}
|
||||
}
|
||||
symGroupType = nil
|
||||
|
||||
if ctxt.Debugvlog > 1 {
|
||||
// loadlibfull is likely a good place to dump.
|
||||
// Only dump under -v=2 and above.
|
||||
ctxt.dumpsyms()
|
||||
}
|
||||
}
|
||||
|
||||
func (ctxt *Link) dumpsyms() {
|
||||
for _, s := range ctxt.Syms.Allsym {
|
||||
fmt.Printf("%s %s %p %v %v\n", s, s.Type, s, s.Attr.Reachable(), s.Attr.OnList())
|
||||
fmt.Printf("%s %s reachable=%v onlist=%v outer=%v sub=%v\n", s, s.Type, s.Attr.Reachable(), s.Attr.OnList(), s.Outer, s.Sub)
|
||||
for i := range s.R {
|
||||
fmt.Println("\t", s.R[i].Type, s.R[i].Sym)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue