Skip to content

Commit c221969

Browse files
paulcacheuxlmb
authored andcommitted
linker: do not error out when there is nothing in /sys/kernel/btf
9958a4f allowed to perform CO-RE against all kernel modules, but introduced a small regression where kernels with no BTF would fail to perform CO-RE with the manually provided types. This commit fixes the issue by skipping the modules BTF collection if there is nothing in `/sys/kernel/btf`. Signed-off-by: Paul Cacheux <paul.cacheux@datadoghq.com>
1 parent 3de0bd4 commit c221969

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

linker.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"errors"
77
"fmt"
88
"io"
9+
"io/fs"
910
"math"
1011
"slices"
1112
"strings"
@@ -148,7 +149,9 @@ func applyRelocations(insns asm.Instructions, bo binary.ByteOrder, b *btf.Builde
148149
}
149150

150151
modules, err := c.Modules()
151-
if err != nil {
152+
// Ignore ErrNotExists to cater to kernels which have CONFIG_DEBUG_INFO_BTF_MODULES
153+
// or CONFIG_DEBUG_INFO_BTF disabled.
154+
if err != nil && !errors.Is(err, fs.ErrNotExist) {
152155
return err
153156
}
154157

0 commit comments

Comments
 (0)