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: fix LINUX_HAS_SYSCALL_WRAPPER use with bpf_tracing.h #1201

Closed
wants to merge 1 commit into from
Closed
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
8 changes: 4 additions & 4 deletions collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -626,17 +626,17 @@ func resolveKconfig(m *MapSpec) error {
internal.NativeEndian.PutUint32(data[vsi.Offset:], kv.Kernel())

case "LINUX_HAS_SYSCALL_WRAPPER":
if integer, ok := v.Type.(*btf.Int); !ok || integer.Size != 4 {
return fmt.Errorf("variable %s must be a 32 bits integer, got %s", n, v.Type)
if integer, ok := v.Type.(*btf.Int); !ok || integer.Size != 1 {
return fmt.Errorf("variable %s must be a 8 bit integer, got %v", n, v.Type)
}
var value uint32 = 1
var value uint8 = 1
if err := haveSyscallWrapper(); errors.Is(err, ErrNotSupported) {
value = 0
} else if err != nil {
return fmt.Errorf("unable to derive a value for LINUX_HAS_SYSCALL_WRAPPER: %w", err)
}

internal.NativeEndian.PutUint32(data[vsi.Offset:], value)
data[vsi.Offset] = value

default: // Catch CONFIG_*.
configs[n] = configInfo{
Expand Down
Binary file modified testdata/kconfig-eb.elf
Binary file not shown.
Binary file modified testdata/kconfig-el.elf
Binary file not shown.
2 changes: 1 addition & 1 deletion testdata/kconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
char __license[] __section("license") = "MIT";

extern int LINUX_KERNEL_VERSION __kconfig;
extern int LINUX_HAS_SYSCALL_WRAPPER __kconfig;
extern _Bool LINUX_HAS_SYSCALL_WRAPPER __kconfig;

__section("socket") int kernel_version() {
return LINUX_KERNEL_VERSION;
Expand Down