bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 bpf-next] libbpf: emit diff of mismatched public API, if any
@ 2019-05-22 17:51 Andrii Nakryiko
  2019-05-23  1:37 ` Alexei Starovoitov
  0 siblings, 1 reply; 2+ messages in thread
From: Andrii Nakryiko @ 2019-05-22 17:51 UTC (permalink / raw)
  To: andrii.nakryiko, netdev, bpf, ast, daniel; +Cc: Andrii Nakryiko

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>
---
 tools/lib/bpf/Makefile | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/tools/lib/bpf/Makefile b/tools/lib/bpf/Makefile
index f91639bf5650..a2aceadf68db 100644
--- a/tools/lib/bpf/Makefile
+++ b/tools/lib/bpf/Makefile
@@ -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
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2 bpf-next] libbpf: emit diff of mismatched public API, if any
  2019-05-22 17:51 [PATCH v2 bpf-next] libbpf: emit diff of mismatched public API, if any Andrii Nakryiko
@ 2019-05-23  1:37 ` Alexei Starovoitov
  0 siblings, 0 replies; 2+ messages in thread
From: Alexei Starovoitov @ 2019-05-23  1:37 UTC (permalink / raw)
  To: Andrii Nakryiko
  Cc: Andrii Nakryiko, Network Development, bpf, Alexei Starovoitov,
	Daniel Borkmann

On Wed, May 22, 2019 at 10:53 AM Andrii Nakryiko <andriin@fb.com> wrote:
>
> 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>

Applied. Thanks

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-05-23  1:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-22 17:51 [PATCH v2 bpf-next] libbpf: emit diff of mismatched public API, if any Andrii Nakryiko
2019-05-23  1:37 ` Alexei Starovoitov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).