• Andrii Nakryiko's avatar
    libbpf: Deprecate btf__finalize_data() and move it into libbpf.c · b96c07f3
    Andrii Nakryiko authored
    There isn't a good use case where anyone but libbpf itself needs to call
    btf__finalize_data(). It was implemented for internal use and it's not
    clear why it was made into public API in the first place. To function, it
    requires active ELF data, which is stored inside bpf_object for the
    duration of opening phase only. But the only BTF that needs bpf_object's
    ELF is that bpf_object's BTF itself, which libbpf fixes up automatically
    during bpf_object__open() operation anyways. There is no need for any
    additional fix up and no reasonable scenario where it's useful and
    appropriate.
    
    Thus, btf__finalize_data() is just an API atavism and is better removed.
    So this patch marks it as deprecated immediately (v0.6+) and moves the
    code from btf.c into libbpf.c where it's used in the context of
    bpf_object opening phase. Such code co-location allows to make code
    structure more straightforward and remove bpf_object__section_size() and
    bpf_object__variable_offset() internal helpers from libbpf_internal.h,
    making them static. Their naming is also adjusted to not create
    a wrong illusion that they are some sort of method of bpf_object. They
    are internal helpers and are called appropriately.
    
    This is part of libbpf 1.0 effort ([0]).
    
      [0] Closes: https://github.com/libbpf/libbpf/issues/276Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
    Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
    Acked-by: default avatarSong Liu <songliubraving@fb.com>
    Link: https://lore.kernel.org/bpf/20211021014404.2635234-2-andrii@kernel.org
    b96c07f3
btf.h 17.2 KB