libbpf: emit diff of mismatched public API, if any
authorAndrii Nakryiko <andriin@fb.com>
Wed, 22 May 2019 17:51:28 +0000 (10:51 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Thu, 23 May 2019 01:34:01 +0000 (18:34 -0700)
It's easy to have a mismatch of "intended to be public" vs really
exposed API functions. While Makefile does check for this mismatch, if
it actually occurs it's not trivial to determine which functions are
accidentally exposed. This patch dumps out a diff showing what's not
supposed to be exposed facilitating easier fixing.

Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/lib/bpf/Makefile

index f91639b..a2acead 100644 (file)
@@ -204,6 +204,16 @@ check_abi: $(OUTPUT)libbpf.so
                     "versioned symbols in $^ ($(VERSIONED_SYM_COUNT))." \
                     "Please make sure all LIBBPF_API symbols are"       \
                     "versioned in $(VERSION_SCRIPT)." >&2;              \
+               readelf -s --wide $(OUTPUT)libbpf-in.o |                 \
+                   awk '/GLOBAL/ && /DEFAULT/ && !/UND/ {print $$8}'|   \
+                   sort -u > $(OUTPUT)libbpf_global_syms.tmp;           \
+               readelf -s --wide $(OUTPUT)libbpf.so |                   \
+                   grep -Eo '[^ ]+@LIBBPF_' | cut -d@ -f1 |             \
+                   sort -u > $(OUTPUT)libbpf_versioned_syms.tmp;        \
+               diff -u $(OUTPUT)libbpf_global_syms.tmp                  \
+                    $(OUTPUT)libbpf_versioned_syms.tmp;                 \
+               rm $(OUTPUT)libbpf_global_syms.tmp                       \
+                  $(OUTPUT)libbpf_versioned_syms.tmp;                   \
                exit 1;                                                  \
        fi