Skip to content

Commit 355915b

Browse files
aarzilliianlancetaylor
authored andcommitted
[release-branch.go1.16] debug/pe,debug/macho: add support for DWARF5 sections
Adds the same logic used in debug/elf to load DWARF5 sections. For #49590 Fixes #50721 Change-Id: Iee05b9927a6f521842b330eab8942ade3fc2bd86 Reviewed-on: https://go-review.googlesource.com/c/go/+/363895 Reviewed-by: Ian Lance Taylor <[email protected]> Trust: Than McIntosh <[email protected]> (cherry picked from commit 6c36c33) Reviewed-on: https://go-review.googlesource.com/c/go/+/379915 Trust: Ian Lance Taylor <[email protected]> Run-TryBot: Ian Lance Taylor <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Alessandro Arzilli <[email protected]> Reviewed-by: Emmanuel Odeke <[email protected]>
1 parent 07ee9e6 commit 355915b

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

src/debug/macho/file.go

+11-3
Original file line numberDiff line numberDiff line change
@@ -650,10 +650,14 @@ func (f *File) DWARF() (*dwarf.Data, error) {
650650
return nil, err
651651
}
652652

653-
// Look for DWARF4 .debug_types sections.
653+
// Look for DWARF4 .debug_types sections and DWARF5 sections.
654654
for i, s := range f.Sections {
655655
suffix := dwarfSuffix(s)
656-
if suffix != "types" {
656+
if suffix == "" {
657+
continue
658+
}
659+
if _, ok := dat[suffix]; ok {
660+
// Already handled.
657661
continue
658662
}
659663

@@ -662,7 +666,11 @@ func (f *File) DWARF() (*dwarf.Data, error) {
662666
return nil, err
663667
}
664668

665-
err = d.AddTypes(fmt.Sprintf("types-%d", i), b)
669+
if suffix == "types" {
670+
err = d.AddTypes(fmt.Sprintf("types-%d", i), b)
671+
} else {
672+
err = d.AddSection(".debug_"+suffix, b)
673+
}
666674
if err != nil {
667675
return nil, err
668676
}

src/debug/pe/file.go

+11-3
Original file line numberDiff line numberDiff line change
@@ -267,10 +267,14 @@ func (f *File) DWARF() (*dwarf.Data, error) {
267267
return nil, err
268268
}
269269

270-
// Look for DWARF4 .debug_types sections.
270+
// Look for DWARF4 .debug_types sections and DWARF5 sections.
271271
for i, s := range f.Sections {
272272
suffix := dwarfSuffix(s)
273-
if suffix != "types" {
273+
if suffix == "" {
274+
continue
275+
}
276+
if _, ok := dat[suffix]; ok {
277+
// Already handled.
274278
continue
275279
}
276280

@@ -279,7 +283,11 @@ func (f *File) DWARF() (*dwarf.Data, error) {
279283
return nil, err
280284
}
281285

282-
err = d.AddTypes(fmt.Sprintf("types-%d", i), b)
286+
if suffix == "types" {
287+
err = d.AddTypes(fmt.Sprintf("types-%d", i), b)
288+
} else {
289+
err = d.AddSection(".debug_"+suffix, b)
290+
}
283291
if err != nil {
284292
return nil, err
285293
}

0 commit comments

Comments
 (0)