aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlessandro Arzilli <alessandro.arzilli@gmail.com>2021-11-15 10:14:04 +0100
committerIan Lance Taylor <iant@golang.org>2022-02-03 20:56:11 +0000
commit355915ba9105cad1b0300de1ff1ef30ee643379c (patch)
treece55f703fc982fa83afc0260928d14c28d47ded0
parent07ee9e6445057e181fb3895df978748ffef30327 (diff)
downloadgo-355915ba9105cad1b0300de1ff1ef30ee643379c.tar.gz
go-355915ba9105cad1b0300de1ff1ef30ee643379c.zip
[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 <iant@golang.org> Trust: Than McIntosh <thanm@google.com> (cherry picked from commit 6c36c332fefdd433cfe6e6468a2542fc310e9f8a) Reviewed-on: https://go-review.googlesource.com/c/go/+/379915 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Alessandro Arzilli <alessandro.arzilli@gmail.com> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
-rw-r--r--src/debug/macho/file.go14
-rw-r--r--src/debug/pe/file.go14
2 files changed, 22 insertions, 6 deletions
diff --git a/src/debug/macho/file.go b/src/debug/macho/file.go
index 73cfce3c76..cdc500e476 100644
--- a/src/debug/macho/file.go
+++ b/src/debug/macho/file.go
@@ -650,10 +650,14 @@ func (f *File) DWARF() (*dwarf.Data, error) {
return nil, err
}
- // Look for DWARF4 .debug_types sections.
+ // Look for DWARF4 .debug_types sections and DWARF5 sections.
for i, s := range f.Sections {
suffix := dwarfSuffix(s)
- if suffix != "types" {
+ if suffix == "" {
+ continue
+ }
+ if _, ok := dat[suffix]; ok {
+ // Already handled.
continue
}
@@ -662,7 +666,11 @@ func (f *File) DWARF() (*dwarf.Data, error) {
return nil, err
}
- err = d.AddTypes(fmt.Sprintf("types-%d", i), b)
+ if suffix == "types" {
+ err = d.AddTypes(fmt.Sprintf("types-%d", i), b)
+ } else {
+ err = d.AddSection(".debug_"+suffix, b)
+ }
if err != nil {
return nil, err
}
diff --git a/src/debug/pe/file.go b/src/debug/pe/file.go
index 7d763fff19..7987730858 100644
--- a/src/debug/pe/file.go
+++ b/src/debug/pe/file.go
@@ -267,10 +267,14 @@ func (f *File) DWARF() (*dwarf.Data, error) {
return nil, err
}
- // Look for DWARF4 .debug_types sections.
+ // Look for DWARF4 .debug_types sections and DWARF5 sections.
for i, s := range f.Sections {
suffix := dwarfSuffix(s)
- if suffix != "types" {
+ if suffix == "" {
+ continue
+ }
+ if _, ok := dat[suffix]; ok {
+ // Already handled.
continue
}
@@ -279,7 +283,11 @@ func (f *File) DWARF() (*dwarf.Data, error) {
return nil, err
}
- err = d.AddTypes(fmt.Sprintf("types-%d", i), b)
+ if suffix == "types" {
+ err = d.AddTypes(fmt.Sprintf("types-%d", i), b)
+ } else {
+ err = d.AddSection(".debug_"+suffix, b)
+ }
if err != nil {
return nil, err
}