cmd/compile: fix bug in DWARF inl handling of unused autos

The DWARF inline info generation hooks weren't properly
handling unused auto vars in certain cases, triggering an assert (now
fixed). Also with this change, introduce a new autom "flavor" to
use for autom entries that are added to insure that a specific
auto type makes it into the linker (this is a follow-on to the fix
for 22941).

Fixes #22962.

Change-Id: I7a2d8caf47f6ca897b12acb6a6de0eb25f5cac8f
Reviewed-on: https://go-review.googlesource.com/81557
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
This commit is contained in:
Than McIntosh 2017-12-01 15:23:30 -05:00
parent 03c93eaa0b
commit 88c2fb9d04
9 changed files with 52 additions and 7 deletions

View file

@ -1964,6 +1964,7 @@ func doversion() {
type SymbolType int8
const (
// see also http://9p.io/magic/man2html/1/nm
TextSym SymbolType = 'T'
DataSym = 'D'
BSSSym = 'B'
@ -1972,6 +1973,9 @@ const (
FrameSym = 'm'
ParamSym = 'p'
AutoSym = 'a'
// Deleted auto (not a real sym, just placeholder for type)
DeletedAutoSym = 'x'
)
func genasmsym(ctxt *Link, put func(*Link, *sym.Symbol, string, SymbolType, int64, *sym.Symbol)) {
@ -2096,6 +2100,11 @@ func genasmsym(ctxt *Link, put func(*Link, *sym.Symbol, string, SymbolType, int6
continue
}
for _, a := range s.FuncInfo.Autom {
if a.Name == objabi.A_DELETED_AUTO {
put(ctxt, nil, "", DeletedAutoSym, 0, a.Gotype)
continue
}
// Emit a or p according to actual offset, even if label is wrong.
// This avoids negative offsets, which cannot be encoded.
if a.Name != objabi.A_AUTO && a.Name != objabi.A_PARAM {