Skip to content

Commit

Permalink
Fix unresovled kernel symbols when /proc/kallsyms is not sorted
Browse files Browse the repository at this point in the history
  • Loading branch information
zmj64351508 committed Sep 23, 2024
1 parent db264c0 commit 52350fc
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ebpf/symtab/kallsyms.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"os"
"runtime"
"sort"
"strconv"
)

Expand Down Expand Up @@ -94,5 +95,9 @@ func NewKallsymsFromData(kallsyms []byte) (*SymbolTab, error) {
if allZeros {
return NewSymbolTab(nil), nil
}
// kallsyms maybe unsorted when bpf/modules are loaded from userspace after kernel boot.
sort.Slice(syms, func(i, j int) bool {
return syms[i].Start < syms[j].Start
})
return NewSymbolTab(syms), nil
}

0 comments on commit 52350fc

Please sign in to comment.