• Andrey Ignatov's avatar
    libbpf: Verify versioned symbols · 306b267c
    Andrey Ignatov authored
    Since ABI versioning info is kept separately from the code it's easy to
    forget to update it while adding a new API.
    
    Add simple verification that all global symbols exported with LIBBPF_API
    are versioned in libbpf.map version script.
    
    The idea is to check that number of global symbols in libbpf-in.o, that
    is the input to the linker, matches with number of unique versioned
    symbols in libbpf.so, that is the output of the linker. If these numbers
    don't match, it may mean some symbol was not versioned and make will
    fail.
    
    "Unique" means that if a symbol is present in more than one version of
    ABI due to ABI changes, it'll be counted once.
    
    Another option to calculate number of global symbols in the "input"
    could be to count number of LIBBPF_ABI entries in C headers but it seems
    to be fragile.
    
    Example of output when a symbol is missing in version script:
    
        ...
        LD       libbpf-in.o
        LINK     libbpf.a
        LINK     libbpf.so
      Warning: Num of global symbols in libbpf-in.o (115) does NOT match
      with num of versioned symbols in libbpf.so (114). Please make sure all
      LIBBPF_API symbols are versioned in libbpf.map.
      make: *** [check_abi] Error 1
    Signed-off-by: default avatarAndrey Ignatov <rdna@fb.com>
    Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
    306b267c
Makefile 7.28 KB