diff options
| author | Joey Jiao <quic_jiangenj@quicinc.com> | 2024-05-23 12:25:55 +0800 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2024-07-01 08:16:05 +0000 |
| commit | b294e901e293e41b6374f056dcc8d4329780455c (patch) | |
| tree | 9a6c4e803b3594cb6e43fe8a127086bf3c2ea33c | |
| parent | 757f06b1fadfe22cb3ac5f4f36e8e894eb78bb08 (diff) | |
pkg/cover: remove symbols having the same Start Address
For modules, init_module and cleanup_module might have the same
sym.Start even these symbols are for different sections.
Although we can keep symbols only in .text sections, there
are still some symbols having the same Start.
Looking forward a better way, but currently to get constant
output in buildSymbols, keep only one symbol incase there
are other symbols having the same Start.
| -rw-r--r-- | pkg/cover/backend/dwarf.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/pkg/cover/backend/dwarf.go b/pkg/cover/backend/dwarf.go index 1eb6dd146..c3941a145 100644 --- a/pkg/cover/backend/dwarf.go +++ b/pkg/cover/backend/dwarf.go @@ -203,6 +203,17 @@ func makeDWARFUnsafe(params *dwarfParams) (*Impl, error) { allRanges = append(allRanges, result.ranges...) allUnits = append(allUnits, result.units...) } + // TODO: need better way to remove symbols having the same Start + uniqSymbs := make(map[uint64]*Symbol) + for _, sym := range allSymbols { + if _, ok := uniqSymbs[sym.Start]; !ok { + uniqSymbs[sym.Start] = sym + } + } + allSymbols = []*Symbol{} + for _, sym := range uniqSymbs { + allSymbols = append(allSymbols, sym) + } sort.Slice(allSymbols, func(i, j int) bool { return allSymbols[i].Start < allSymbols[j].Start }) |
