On 2/28/25 11:46 AM, Ihor Solodrai wrote: > Instead of compile-time checks for libbpf version, use __weak > declarations of the required API functions and do runtime checks at > the call sites. This will help with compatibility when libbpf is > dynamically linked to pahole [1]. > > [1] https://lore.kernel.org/dwarves/deff78f8-1f99-4c79-a302-cff8dce4d803@xxxxxxxxxx/ > > Signed-off-by: Ihor Solodrai <ihor.solodrai@xxxxxxxxx> > --- > btf_encoder.c | 48 +++++++++++++++++++----------------------------- > dwarves.h | 11 ++++++++++- > pahole.c | 2 -- > 3 files changed, 29 insertions(+), 32 deletions(-) > > diff --git a/btf_encoder.c b/btf_encoder.c > index 2bea5ee..12a040f 100644 > --- a/btf_encoder.c > +++ b/btf_encoder.c > @@ -34,6 +34,7 @@ > #include <search.h> /* for tsearch(), tfind() and tdestroy() */ > #include <pthread.h> > > +#define BTF_BASE_ELF_SEC ".BTF.base" > #define BTF_IDS_SECTION ".BTF_ids" > #define BTF_ID_FUNC_PFX "__BTF_ID__func__" > #define BTF_ID_SET8_PFX "__BTF_ID__set8__" > @@ -625,29 +626,6 @@ static int32_t btf_encoder__add_struct(struct btf_encoder *encoder, uint8_t kind > return id; > } > > -#if LIBBPF_MAJOR_VERSION < 1 There is an identical condition in btf_loader.c, however it guards static functions, for example btf_enum64(). I decided to leave it as is, although I find it unlikely that someone would use libbpf < 1.0. > [...]