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

libbpf report error: kernel doesn't support global data #5072

Open
li-xilin opened this issue Jul 31, 2024 · 1 comment
Open

libbpf report error: kernel doesn't support global data #5072

li-xilin opened this issue Jul 31, 2024 · 1 comment

Comments

@li-xilin
Copy link

my kernel release:

~ # uname -a
Linux (none) 4.18.0 #10 SMP Fri Jul 26 10:32:39 CST 2024 x86_64 GNU/Linux

libbpf version is 0.3, to adapt to the version of 4.18 kernel.

...

struct {
	__uint(type, BPF_MAP_TYPE_PERF_EVENT_ARRAY);
	__uint(max_entries, 128);
	__type(key, __u32);
	__type(value, __u32);
} events SEC(".maps");

struct event {
	uint32_t pid;
	uint32_t crc;
	char name[32];
};

SEC("tracepoint/syscalls/sys_exit_init_module")
int func3(struct finit_module_args *ctx)
{
	struct event ev = { .name = "__finished"};
	ev.crc = 0;
	ev.pid = bpf_get_current_pid_tgid();
	// bpf_perf_event_output(ctx, &events, BPF_F_CURRENT_CPU, &ev, sizeof(ev));
	return 0;
}

the code above works fine, but when I enable the commented line bpf_perf_event_output(ctx, &events, BPF_F_CURRENT_CPU, &ev, sizeof(ev));

error occured.

libbpf: loading object '538580-4440' from buffer
libbpf: elf: section(3) kprobe/find_symbol, size 440, link 0, flags 6, type=1
libbpf: sec 'kprobe/find_symbol': found program 'func1' at insn offset 0 (0 bytes), code size 55 insns (440 bytes)
libbpf: elf: section(4) .relkprobe/find_symbol, size 16, link 31, flags 0, type=9
libbpf: elf: section(5) kretprobe/find_symbol, size 144, link 0, flags 6, type=1
libbpf: sec 'kretprobe/find_symbol': found program 'func2' at insn offset 0 (0 bytes), code size 18 insns (144 bytes)
libbpf: elf: section(6) .relkretprobe/find_symbol, size 16, link 31, flags 0, type=9
libbpf: elf: section(7) tracepoint/syscalls/sys_exit_init_module, size 216, link 0, flags 6, type=1
libbpf: sec 'tracepoint/syscalls/sys_exit_init_module': found program 'func3' at insn offset 0 (0 bytes), code size 27 insns (21)
libbpf: elf: section(8) .reltracepoint/syscalls/sys_exit_init_module, size 16, link 31, flags 0, type=9
libbpf: elf: section(9) .maps.events, size 8, link 0, flags 3, type=1
libbpf: elf: skipping unrecognized data section(9) .maps.events
libbpf: elf: section(10) .maps.param_array, size 280, link 0, flags 3, type=1
libbpf: elf: skipping unrecognized data section(10) .maps.param_array
libbpf: elf: section(11) .rodata, size 40, link 0, flags 2, type=1
libbpf: elf: section(12) .maps, size 64, link 0, flags 3, type=1
libbpf: elf: section(13) license, size 4, link 0, flags 3, type=1
libbpf: license of 538580-4440 is GPL
libbpf: elf: section(22) .BTF, size 2850, link 0, flags 0, type=1
libbpf: elf: section(24) .BTF.ext, size 576, link 0, flags 0, type=1
libbpf: elf: section(31) .symtab, size 2640, link 1, flags 0, type=2
libbpf: looking for externs among 110 symbols...
libbpf: collected 0 externs total
libbpf: map 'events': at sec_idx 12, offset 0.
libbpf: map 'events': found type = 4.
libbpf: map 'events': found max_entries = 128.
libbpf: map 'events': found key [1], sz = 4.
libbpf: map 'events': found value [1], sz = 4.
libbpf: map 'param_array': at sec_idx 12, offset 32.
libbpf: map 'param_array': found type = 2.
libbpf: map 'param_array': found max_entries = 1.
libbpf: map 'param_array': found key [1], sz = 4.
libbpf: map 'param_array': found value [7], sz = 272.
libbpf: map '538580_4.rodata' (global data): at sec_idx 11, offset 0, flags 480.
libbpf: map 2 is "538580_4.rodata"
libbpf: sec '.relkprobe/find_symbol': collecting relocation for section(3) 'kprobe/find_symbol'
libbpf: sec '.relkprobe/find_symbol': relo #0: insn #48 against 'param_array'
libbpf: prog 'func1': found map 1 (param_array, sec 12, off 32) for insn #48
libbpf: sec '.relkretprobe/find_symbol': collecting relocation for section(5) 'kretprobe/find_symbol'
libbpf: sec '.relkretprobe/find_symbol': relo #0: insn #6 against 'param_array'
libbpf: prog 'func2': found map 1 (param_array, sec 12, off 32) for insn #6
libbpf: sec '.reltracepoint/syscalls/sys_exit_init_module': collecting relocation for section(7) 'tracepoint/syscalls/sys_exit_i'
libbpf: sec '.reltracepoint/syscalls/sys_exit_init_module': relo #0: insn #19 against 'events'
libbpf: prog 'func3': found map 0 (events, sec 12, off 0) for insn #19
libbpf: kernel doesn't support global data
libbpf: failed to load object '538580-4440'

Thanks.

@yonghong-song
Copy link
Collaborator

See 'libbpf: kernel doesn't support global data'. You need newer kernel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants