1
0
mirror of https://github.com/golang/go synced 2024-11-18 15:04:44 -07:00

cmd/link: let writelines work when pcstmt symbol doesn't exist

The assembler does not produce pcstmt symbols, writeline should be able
to work even if no pcstmt symbol exists for a given function.

Fixes #25216, #25191

Change-Id: I41e16df1e7c8ca59d27e7514537609e309a51c51
Reviewed-on: https://go-review.googlesource.com/110816
Reviewed-by: David Chase <drchase@google.com>
This commit is contained in:
Alessandro Arzilli 2018-05-02 12:45:47 +02:00 committed by David Chase
parent fc9c69a693
commit 836fe697c4

View File

@ -1249,9 +1249,15 @@ func writelines(ctxt *Link, lib *sym.Library, textp []*sym.Symbol, ls *sym.Symbo
pciterinit(ctxt, &pcline, &s.FuncInfo.Pcline) pciterinit(ctxt, &pcline, &s.FuncInfo.Pcline)
pciterinit(ctxt, &pcstmt, &pctostmtData) pciterinit(ctxt, &pcstmt, &pctostmtData)
if pcstmt.done != 0 {
// Assembly files lack a pcstmt section, we assume that every instruction
// is a valid statement.
pcstmt.value = 1
}
var thispc uint32 var thispc uint32
// TODO this loop looks like it could exit with work remaining. // TODO this loop looks like it could exit with work remaining.
for pcfile.done == 0 && pcline.done == 0 && pcstmt.done == 0 { for pcfile.done == 0 && pcline.done == 0 {
// Only changed if it advanced // Only changed if it advanced
if int32(file) != pcfile.value { if int32(file) != pcfile.value {
ls.AddUint8(dwarf.DW_LNS_set_file) ls.AddUint8(dwarf.DW_LNS_set_file)
@ -1280,14 +1286,14 @@ func writelines(ctxt *Link, lib *sym.Library, textp []*sym.Symbol, ls *sym.Symbo
if pcline.nextpc < thispc { if pcline.nextpc < thispc {
thispc = pcline.nextpc thispc = pcline.nextpc
} }
if pcstmt.nextpc < thispc { if pcstmt.done == 0 && pcstmt.nextpc < thispc {
thispc = pcstmt.nextpc thispc = pcstmt.nextpc
} }
if pcfile.nextpc == thispc { if pcfile.nextpc == thispc {
pciternext(&pcfile) pciternext(&pcfile)
} }
if pcstmt.nextpc == thispc { if pcstmt.done == 0 && pcstmt.nextpc == thispc {
pciternext(&pcstmt) pciternext(&pcstmt)
} }
if pcline.nextpc == thispc { if pcline.nextpc == thispc {