shared_lib: only export spdk_* symbols

Add a basic linker version script to limit exported symbols to those
intended to be public API.  Currently, many internal-only functions are
also named spdk_*, but this will at least limit exported symbols to
those that will not pollute the global namespace.

This also does not assign a version to any symbols; in the future, we
may want to extend the version script to enable ABI compatibility, but
for now, the version script is just used to control symbol visibility.

Change-Id: I1f020300b3288a026b47e9b1466ebc72952d9401
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/415897
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Daniel Verkamp 2018-06-18 16:26:20 -07:00 committed by Jim Harris
parent f387d32133
commit 9259324ffb
3 changed files with 6 additions and 2 deletions

1
.gitignore vendored
View File

@ -7,7 +7,6 @@
*.kdev4
*.ko
*.log
*.map
*.o
*.pyc
*.so

View File

@ -83,13 +83,14 @@ LIBS += $(ENV_LINKER_ARGS)
comma := ,
$(SHARED_LIB): $(SPDK_LIB_FILES) $(SPDK_WHOLE_LIBS) $(BLOCKDEV_MODULES_FILES) $(COPY_MODULES_FILES) $(NET_MODULES_FILES) $(LINKER_MODULES) $(ENV_LIBS) $(MAKEFILE_LIST)
$(SHARED_LIB): $(SPDK_LIB_FILES) $(SPDK_WHOLE_LIBS) $(BLOCKDEV_MODULES_FILES) $(COPY_MODULES_FILES) $(NET_MODULES_FILES) $(LINKER_MODULES) $(ENV_LIBS) $(MAKEFILE_LIST) spdk.map
$(Q)echo " SO $(notdir $@)"; \
rm -f $@; \
$(CC) -o $@ -shared $(CPPFLAGS) $(LDFLAGS) \
-Wl,--whole-archive \
$(filter-out -Wl$(comma)--no-whole-archive,$(LIBS)) \
-Wl,--no-whole-archive \
-Wl,--version-script=spdk.map \
-lcrypto \
$(SYS_LIBS)

4
shared_lib/spdk.map Normal file
View File

@ -0,0 +1,4 @@
{
global: spdk_*;
local: *;
};