Skip to content

Commit e6adccb

Browse files
abrachetdr2chase
authored andcommitted
[release-branch.go1.18] 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 #57044 Updates #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]> (cherry picked from commit e66f895) Change-Id: I2cf063160508687067c7672cef0517bccd707d7b GitHub-Last-Rev: 32208e4 GitHub-Pull-Request: #57067 Reviewed-on: https://go-review.googlesource.com/c/go/+/455055 Reviewed-by: Ian Lance Taylor <[email protected]> Run-TryBot: David Chase <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
1 parent 6aa1e6d commit e6adccb

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/cmd/cgo/gcc.go

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

0 commit comments

Comments
 (0)