On Tue, Mar 2, 2021 at 4:42 PM <bg.salunk...@gmail.com> wrote:
>
> Thanks Andrii, for detailed answer.
> Yes you are right, I'm looking for CO-RE. Basically I'm trying to build the 
> eBPF program which can run on any linux kernel version using libbpf
>
> What I understood from your blog 
> https://facebookmicrosites.github.io/bpf/blog/2020/02/19/bpf-portability-and-co-re.html
>  (Thanks for in depth blog post, appreciate it), to work libbpf based program
> the BTF information should be available on the running host. Is my 
> understanding correct?

Yes, correct.

>
> Btw, Is there any document to generate BTF information for a linux kernel?  
> Or Is there a way to generate BTF info for running kernel i.e. at runtime and 
> not at compile time? Thanks!

Yes, you can, if you have vmlinux image with DWARF information in it.
You can use pahole tool like this to add .BTF section to vmlinux
image:

pahole -J <path-to-vmlinux-image>

You most probably would want to make a local copy of vmlinux image, of
course. After that you can pass the path to that vmlinux with embedded
.BTF to libbpf to use for CO-RE relocations. See [0] for recent
discussion of the exact same topic. See also patch [1] that was aiming
to make this scenario better in libbpf (unfortunately it hasn't landed
yet, but it is pretty close to being done, so shouldn't be a problem
for you to pick up, if necessary).

This is certainly not the most straightforward and easiest path, but
if you want to get CO-RE working with older kernel for which you don't
have much control, it is definitely a possible way (as long as you
have DWARF, which is used to produce BTF for vmlinux).

  [0] 
https://lore.kernel.org/bpf/CAEf4BzbJZLjNoiK8_VfeVg_Vrg=9iYFv+po-38SMe=UzwDKJ=q...@mail.gmail.com/
  [1] 
https://lore.kernel.org/bpf/b8801f77-37e8-4ef8-8994-d366d4816...@araalinetworks.com/


> 


-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#1969): https://lists.iovisor.org/g/iovisor-dev/message/1969
Mute This Topic: https://lists.iovisor.org/mt/80980657/21656
Mute #bcc:https://lists.iovisor.org/g/iovisor-dev/mutehashtag/bcc
Group Owner: iovisor-dev+ow...@lists.iovisor.org
Unsubscribe: https://lists.iovisor.org/g/iovisor-dev/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-


Reply via email to