Skip to content

Commit

Permalink
Fix kconfig symbol address
Browse files Browse the repository at this point in the history
  • Loading branch information
davibe committed Sep 27, 2024
1 parent d1e8243 commit 976f0ef
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion aya-obj/src/btf/btf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -889,8 +889,8 @@ impl Object {
section_data.resize((symbol.address - offset) as usize, 0);

self.symbol_offset_by_name.insert(name, symbol.address);
offset = symbol.address + section_data.len() as u64;
section_data.extend(data);
offset = symbol.address + data.len() as u64;
} else {
return Err(BtfError::ExternalSymbolNotFound { symbol_name: name });
}
Expand Down
15 changes: 14 additions & 1 deletion test/integration-test/bpf/kconfig.bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,24 @@
#include <bpf/bpf_helpers.h>
// clang-format on

// CONFIG_BPF=y => 1
extern unsigned int CONFIG_BPF __kconfig;
// CONFIG_PANIC_TIMEOUT=0 => 0
extern unsigned int CONFIG_PANIC_TIMEOUT __kconfig;
// CONFIG_DEFAULT_HUNG_TASK_TIMEOUT=120
extern unsigned int CONFIG_DEFAULT_HUNG_TASK_TIMEOUT __kconfig;

SEC("xdp")
int kconfig(struct xdp_md *ctx) {
if (!CONFIG_BPF) {
if (CONFIG_BPF != 1) {
return XDP_DROP;
}

if (CONFIG_PANIC_TIMEOUT != 0) {
return XDP_DROP;
}

if (CONFIG_DEFAULT_HUNG_TASK_TIMEOUT != 120) {
return XDP_DROP;
}

Expand Down

0 comments on commit 976f0ef

Please sign in to comment.