Skip to content

Commit

Permalink
btf: support both elf and raw BTF in loadKernelSpec
Browse files Browse the repository at this point in the history
Signed-off-by: Wang Xingxing <[email protected]>
  • Loading branch information
wxx213 committed Oct 19, 2023
1 parent c42caeb commit af0cdcc
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions btf/btf.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,12 +322,12 @@ func loadKernelSpec() (_ *Spec, fallback bool, _ error) {
}
defer file.Close()

spec, err := loadSpecFromELF(file)
spec, err := LoadSpecFromReader(file)
return spec, true, err
}

// findVMLinux scans multiple well-known paths for vmlinux kernel images.
func findVMLinux() (*internal.SafeELFFile, error) {
func findVMLinux() (*os.File, error) {
release, err := internal.KernelRelease()
if err != nil {
return nil, err
Expand All @@ -346,7 +346,7 @@ func findVMLinux() (*internal.SafeELFFile, error) {
}

for _, loc := range locations {
file, err := internal.OpenSafeELFFile(fmt.Sprintf(loc, release))
file, err := os.Open(fmt.Sprintf(loc, release))
if errors.Is(err, os.ErrNotExist) {
continue
}
Expand Down

0 comments on commit af0cdcc

Please sign in to comment.