From 9259324ffb9a4ce6fae8dd19d617bd265fa29c8d Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Mon, 18 Jun 2018 16:26:20 -0700 Subject: [PATCH] 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 Reviewed-on: https://review.gerrithub.io/415897 Tested-by: SPDK Automated Test System Reviewed-by: Ben Walker Reviewed-by: Jim Harris --- .gitignore | 1 - shared_lib/Makefile | 3 ++- shared_lib/spdk.map | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 shared_lib/spdk.map diff --git a/.gitignore b/.gitignore index 0a193fea7..bb07e034f 100644 --- a/.gitignore +++ b/.gitignore @@ -7,7 +7,6 @@ *.kdev4 *.ko *.log -*.map *.o *.pyc *.so diff --git a/shared_lib/Makefile b/shared_lib/Makefile index 5819af149..8bf88222d 100644 --- a/shared_lib/Makefile +++ b/shared_lib/Makefile @@ -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) diff --git a/shared_lib/spdk.map b/shared_lib/spdk.map new file mode 100644 index 000000000..9467260da --- /dev/null +++ b/shared_lib/spdk.map @@ -0,0 +1,4 @@ +{ + global: spdk_*; + local: *; +};