Skip to content

Commit

Permalink
Use arch-specific vmlinux.h, provide it for x86 and arm64
Browse files Browse the repository at this point in the history
  • Loading branch information
bobrik committed Oct 16, 2022
1 parent af47b1c commit 5fd530b
Show file tree
Hide file tree
Showing 6 changed files with 291,024 additions and 74,115 deletions.
4 changes: 3 additions & 1 deletion benchmark/probes/Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
CC := clang

ARCH := $(shell uname -m | sed -e 's/x86_64/x86/' -e 's/aarch64/arm64/')

SRC = ${wildcard *.bpf.c}
OBJ = ${patsubst %.bpf.c, %.bpf.o, $(SRC)}

$(OBJ): %.bpf.o: %.bpf.c
$(CC) -g -O2 -I../../include -c -target bpf $< -o $@
$(CC) -g -O2 -I../../include/$(ARCH) -c -target bpf $< -o $@

.PHONY: clean
clean:
Expand Down
2 changes: 1 addition & 1 deletion examples/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ SRC = ${wildcard *.bpf.c}
OBJ = ${patsubst %.bpf.c, %.bpf.o, $(SRC)}

$(OBJ): %.bpf.o: %.bpf.c
$(CC) -g -O2 -Wall -D__TARGET_ARCH_$(ARCH) -I../include -c -target bpf $< -o $@
$(CC) -g -O2 -Wall -D__TARGET_ARCH_$(ARCH) -I../include/$(ARCH) -c -target bpf $< -o $@

.PHONY: clean
clean:
Expand Down
14 changes: 12 additions & 2 deletions include/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
# `vmlinux.h`

This file is synthesized by `bpftool` from BTF information in the kernel.
Most of it is arch independent, but some bits like registers depend on
the target architecture, so it's easiest to make it per architecture.

To regenerate it use the following command:
The files here were generated from Ubuntu 22.04 and Linux 5.15 kernel:

* https://bugs.launchpad.net/ubuntu/jammy/+package/linux-image-unsigned-5.15.0-25-generic-dbgsym

To regenerate the files, download both amd64 and arm64 ddbg files from above,
then run the following command on each to get the `vmlinux.h` contents:

```
sudo bpftool btf dump file /sys/kernel/btf/vmlinux format c > vmlinux.h
rm -rf /tmp/ddbg
mkdir /tmp/ddbg
dpkg-deb -x linux-image-unsigned-5.15.0-25-generic-dbgsym_5.15.0-25.25_arm64.ddeb /tmp/ddbg/
sudo bpftool btf dump file /tmp/ddbg/usr/lib/debug/boot/vmlinux-5.15.0-25-generic format c
```

For more information see `libbpf-bootstrap` documentation:
Expand Down
Loading

0 comments on commit 5fd530b

Please sign in to comment.