Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

program: don't return error when kmod BTF is disabled #1440

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions btf/kernel.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ func LoadKernelSpec() (*Spec, error) {
//
// Defaults to /sys/kernel/btf/<module>.
// Returns an error wrapping ErrNotSupported if BTF is not enabled.
// Returns an error wrapping fs.ErrNotExist if BTF for the specific module doesn't exist.
func LoadKernelModuleSpec(module string) (*Spec, error) {
kernelBTF.RLock()
spec := kernelBTF.modules[module]
Expand Down
8 changes: 6 additions & 2 deletions linker.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"errors"
"fmt"
"io"
"io/fs"
"math"
"slices"

Expand Down Expand Up @@ -148,10 +149,13 @@ func applyRelocations(insns asm.Instructions, targets []*btf.Spec, kmodName stri

if kmodName != "" {
kmodTarget, err := btf.LoadKernelModuleSpec(kmodName)
if err != nil {
// Ignore ErrNotExists to cater to kernels which have CONFIG_DEBUG_INFO_BTF_MODULES disabled.
if err != nil && !errors.Is(err, fs.ErrNotExist) {
return fmt.Errorf("load kernel module spec: %w", err)
}
targets = append(targets, kmodTarget)
if err == nil {
targets = append(targets, kmodTarget)
}
}
}

Expand Down