Adds the same logic used in debug/elf to load DWARF5 sections.
For #49590
Fixes #50722
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/+/379914
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>
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
}
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
}
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
}
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
}