Subject: Re: [PATCH bpf-next 3/6] bpf: Introduce function-by-function verification

From: Toke Høiland-Jørgensen <[email-masked]>
Date: Fri, 10 Jan 2020 11:08:00 +0100

Alexei Starovoitov <[email-masked]> writes:

> On Thu, Jan 09, 2020 at 09:57:50AM +0100, Toke Høiland-Jørgensen wrote:
>> 
>> > As far as future plans when libbpf sees FUNC_EXTERN it will do the linking the
>> > way we discussed in the other thread. The kernel will support FUNC_EXTERN when
>> > we introduce dynamic libraries. A collection of bpf functions will be loaded
>> > into the kernel first (like libc.so) and later programs will have FUNC_EXTERN
>> > as part of their BTF to be resolved while loading. The func name to btf_id
>> > resolution will be done by libbpf. The kernel verifier will do the type
>> > checking on BTFs.
>> 
>> Right, FUNC_EXTERN will be rejected by the kernel unless it's patched up
>> with "target" btf_ids by libbpf before load? So it'll be
>> FUNC_GLOBAL-linked functions that will be replaceable after the fact
>> with the "dynamic re-linking" feature?
>
> Right. When libbpf statically links two .o it will need to produce a combined
> BTF out of these two .o. That new BTF will not have FUNC_EXTERN anymore if they
> are resolved. When the kernel sees FUNC_EXTERN it's a directive for the kernel
> to resolve it. BPF program with FUNC_EXTERN references would be loadable, but
> not executable. Anyhow the extern work is not immediate. I don't think any of
> that is necessary for dynamic re-linking.

Right, makes sense. I'll just wait for your follow-up series for the
dynamic re-linking, then. Thanks for the explanation :)

-Toke