Skip to content

Commit e66f895

Browse files
abrachetgopherbot
authored andcommitted
cmd/cgo: allow DW_TAG_variable's with no name
https://reviews.llvm.org/D123534 is emitting DW_TAG_variable's that don't have a DW_AT_name. This is allowed in the DWARF standard. It is adding DIE's for string literals for better symbolization on buffer overlows etc on these strings. They no associated name because they are not user provided variables. Fixes #53000 Change-Id: I2cf063160508687067c7672cef0517bccd707d7b Reviewed-on: https://go-review.googlesource.com/c/go/+/406816 TryBot-Result: Gopher Robot <[email protected]> Run-TryBot: Ian Lance Taylor <[email protected]> Auto-Submit: Ian Lance Taylor <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent 4dd9458 commit e66f895

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/cmd/cgo/gcc.go

+16-1
Original file line numberDiff line numberDiff line change
@@ -576,8 +576,23 @@ func (p *Package) loadDWARF(f *File, conv *typeConv, names []*Name) {
576576
switch e.Tag {
577577
case dwarf.TagVariable:
578578
name, _ := e.Val(dwarf.AttrName).(string)
579+
// As of https://reviews.llvm.org/D123534, clang
580+
// now emits DW_TAG_variable DIEs that have
581+
// no name (so as to be able to describe the
582+
// type and source locations of constant strings
583+
// like the second arg in the call below:
584+
//
585+
// myfunction(42, "foo")
586+
//
587+
// If a var has no name we won't see attempts to
588+
// refer to it via "C.<name>", so skip these vars
589+
//
590+
// See issue 53000 for more context.
591+
if name == "" {
592+
break
593+
}
579594
typOff, _ := e.Val(dwarf.AttrType).(dwarf.Offset)
580-
if name == "" || typOff == 0 {
595+
if typOff == 0 {
581596
if e.Val(dwarf.AttrSpecification) != nil {
582597
// Since we are reading all the DWARF,
583598
// assume we will see the variable elsewhere.

0 commit comments

Comments
 (0)