switch n.Class() {
case PAUTO:
if !n.Name.Used() {
- Fatalf("debuginfo unused node (AllocFrame should truncate fn.Func.Dcl)")
+ // Text == nil -> generating abstract function
+ if fnsym.Func.Text != nil {
+ Fatalf("debuginfo unused node (AllocFrame should truncate fn.Func.Dcl)")
+ }
+ continue
}
name = obj.NAME_AUTO
case PPARAM, PPARAMOUT:
InlIndex: int32(inlIndex),
ChildIndex: -1,
})
- // Note: the auto that we're appending here is simply to insure
- // that the DWARF type in question is picked up by the linker --
- // there isn't a real auto variable with this name. This is
- // to fix issue 22941.
+ // Append a "deleted auto" entry to the autom list so as to
+ // insure that the type in question is picked up by the linker.
+ // See issue 22941.
gotype := ngotype(n).Linksym()
fnsym.Func.Autom = append(fnsym.Func.Autom, &obj.Auto{
Asym: Ctxt.Lookup(n.Sym.Name),
Aoffset: int32(-1),
- Name: obj.NAME_AUTO,
+ Name: obj.NAME_DELETED_AUTO,
Gotype: gotype,
})
// A reference to name@GOT(SB) is a reference to the entry in the global offset
// table for 'name'.
NAME_GOTREF
+ // Indicates auto that was optimized away, but whose type
+ // we want to preserve in the DWARF debug info.
+ NAME_DELETED_AUTO
)
type AddrType uint8
w.writeInt(objabi.A_AUTO)
} else if a.Name == NAME_PARAM {
w.writeInt(objabi.A_PARAM)
+ } else if a.Name == NAME_DELETED_AUTO {
+ w.writeInt(objabi.A_DELETED_AUTO)
} else {
log.Fatalf("%s: invalid local variable type %d", s.Name, a.Name)
}
const (
A_AUTO = 1 + iota
A_PARAM
+ A_DELETED_AUTO
)
}
fallthrough
- case AutoSym, ParamSym:
+ case AutoSym, ParamSym, DeletedAutoSym:
dt = defgotype(ctxt, gotype)
}
type SymbolType int8
const (
+ // see also http://9p.io/magic/man2html/1/nm
TextSym SymbolType = 'T'
DataSym = 'D'
BSSSym = 'B'
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)) {
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 {
--- /dev/null
+// Copyright 2017 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package a
+
+func F() {
+ if x := 0; false {
+ _ = x
+ }
+}
--- /dev/null
+// Copyright 2017 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package b
+
+import "a"
+
+var V = func() { a.F() }
--- /dev/null
+// compiledir
+
+// Copyright 2017 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package ignored