libbpf: Add version script for DSO
authorAndrey Ignatov <rdna@fb.com>
Sat, 24 Nov 2018 00:44:33 +0000 (16:44 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 27 Nov 2018 02:57:14 +0000 (18:57 -0800)
commit16192a771d8c4d844529cbc920c75d170d16fb14
treec6e888d55c0652ebaa75e3c8321808f63c53a689
parent1d2f44ca342445f7da56555ca7a43d19aac8996a
libbpf: Add version script for DSO

More and more projects use libbpf and one day it'll likely be packaged
and distributed as DSO and that requires ABI versioning so that both
compatible and incompatible changes to ABI can be introduced in a safe
way in the future without breaking executables dynamically linked with a
previous version of the library.

Usual way to do ABI versioning is version script for the linker. Add
such a script for libbpf. All global symbols currently exported via
LIBBPF_API macro are added to the version script libbpf.map.

The version name LIBBPF_0.0.1 is constructed from the name of the
library + version specified by $(LIBBPF_VERSION) in Makefile.

Version script does not duplicate the work done by LIBBPF_API macro, it
rather complements it. The macro is used at compile time and can be used
by compiler to do optimization that can't be done at link time, it is
purely about global symbol visibility. The version script, in turn, is
used at link time and takes care of ABI versioning. Both techniques are
described in details in [1].

Whenever ABI is changed in the future, version script should be changed
appropriately.

[1] https://www.akkadia.org/drepper/dsohowto.pdf

Signed-off-by: Andrey Ignatov <rdna@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/lib/bpf/Makefile
tools/lib/bpf/libbpf.map [new file with mode: 0644]