diff options
| author | Cherry Zhang <cherryyz@google.com> | 2020-03-20 16:05:24 -0400 |
|---|---|---|
| committer | Cherry Zhang <cherryyz@google.com> | 2020-03-23 14:39:03 +0000 |
| commit | 6c7d6cefd0ec6653f7f245f3d71a5a3eb7697732 (patch) | |
| tree | abf5cd4e12e37c901828ba129bb3308f9b0bc40c /src/cmd/internal/obj/objfile.go | |
| parent | 330f53b6155954af81d8876a8dc251d8908db581 (diff) | |
| download | go-6c7d6cefd0ec6653f7f245f3d71a5a3eb7697732.tar.xz | |
[dev.link] cmd/internal/obj: restore old DWARF symbol handling
When old object file format is used, serialize DWARF symbols in
the old way.
Change-Id: I73a97f10bba367ac29c52f8f3d0f8f3b34a42523
Reviewed-on: https://go-review.googlesource.com/c/go/+/224624
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Diffstat (limited to 'src/cmd/internal/obj/objfile.go')
| -rw-r--r-- | src/cmd/internal/obj/objfile.go | 49 |
1 files changed, 32 insertions, 17 deletions
diff --git a/src/cmd/internal/obj/objfile.go b/src/cmd/internal/obj/objfile.go index c0f8f9bbb8..3e97c614b8 100644 --- a/src/cmd/internal/obj/objfile.go +++ b/src/cmd/internal/obj/objfile.go @@ -507,11 +507,17 @@ func (c dwCtxt) AddDWARFAddrSectionOffset(s dwarf.Sym, t interface{}, ofs int64) func (c dwCtxt) AddFileRef(s dwarf.Sym, f interface{}) { ls := s.(*LSym) rsym := f.(*LSym) - fidx := c.Link.PosTable.FileIndex(rsym.Name) - // Note the +1 here -- the value we're writing is going to be an - // index into the DWARF line table file section, whose entries - // are numbered starting at 1, not 0. - ls.WriteInt(c.Link, ls.Size, 4, int64(fidx+1)) + if c.Link.Flag_go115newobj { + fidx := c.Link.PosTable.FileIndex(rsym.Name) + // Note the +1 here -- the value we're writing is going to be an + // index into the DWARF line table file section, whose entries + // are numbered starting at 1, not 0. + ls.WriteInt(c.Link, ls.Size, 4, int64(fidx+1)) + } else { + ls.WriteAddr(c.Link, ls.Size, 4, rsym, 0) + r := &ls.R[len(ls.R)-1] + r.Type = objabi.R_DWARFFILEREF + } } func (c dwCtxt) CurrentOffset(s dwarf.Sym) int64 { @@ -549,23 +555,32 @@ func (ctxt *Link) dwarfSym(s *LSym) (dwarfInfoSym, dwarfLocSym, dwarfRangesSym, ctxt.Diag("dwarfSym of non-TEXT %v", s) } if s.Func.dwarfInfoSym == nil { - s.Func.dwarfInfoSym = &LSym{ - Type: objabi.SDWARFINFO, - } - if ctxt.Flag_locationlists { - s.Func.dwarfLocSym = &LSym{ - Type: objabi.SDWARFLOC, + if ctxt.Flag_go115newobj { + s.Func.dwarfInfoSym = &LSym{ + Type: objabi.SDWARFINFO, } - } - s.Func.dwarfRangesSym = &LSym{ - Type: objabi.SDWARFRANGE, + if ctxt.Flag_locationlists { + s.Func.dwarfLocSym = &LSym{ + Type: objabi.SDWARFLOC, + } + } + s.Func.dwarfRangesSym = &LSym{ + Type: objabi.SDWARFRANGE, + } + s.Func.dwarfDebugLinesSym = &LSym{ + Type: objabi.SDWARFLINES, + } + } else { + s.Func.dwarfInfoSym = ctxt.LookupDerived(s, dwarf.InfoPrefix+s.Name) + if ctxt.Flag_locationlists { + s.Func.dwarfLocSym = ctxt.LookupDerived(s, dwarf.LocPrefix+s.Name) + } + s.Func.dwarfRangesSym = ctxt.LookupDerived(s, dwarf.RangePrefix+s.Name) + s.Func.dwarfDebugLinesSym = ctxt.LookupDerived(s, dwarf.DebugLinesPrefix+s.Name) } if s.WasInlined() { s.Func.dwarfAbsFnSym = ctxt.DwFixups.AbsFuncDwarfSym(s) } - s.Func.dwarfDebugLinesSym = &LSym{ - Type: objabi.SDWARFLINES, - } } return s.Func.dwarfInfoSym, s.Func.dwarfLocSym, s.Func.dwarfRangesSym, s.Func.dwarfAbsFnSym, s.Func.dwarfDebugLinesSym } |
