Skip to contentSkip to conversation

mk: fix compile error and ABI versioning for combined shared library

PATCH Superseded Ferruh Yigit 4 participants 12 messages Dec 3, 2015 – Dec 6, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 mk: fix compile error and ABI versioning for combined shared library

Fixes following error (observed when versioning macros used):
LD libdpdk.so
/usr/bin/ld: /root/dpdk/build/lib/libdpdk.so: version node not found for symbol <function>@DPDK_x.y

Also resulting combined library contains symbol version information:

$ readelf -a build/lib/libdpdk.so | grep rte_eal_ | grep @ | head
   <...>    GLOBAL DEFAULT   12 rte_eal_alarm_set@@DPDK_2.0
   <...>    GLOBAL DEFAULT   12 rte_eal_pci_write_config@@DPDK_2.1
   <...>    GLOBAL DEFAULT   12 rte_eal_remote_launch@@DPDK_2.0
...

Versioning fixed by merging all version scripts into one automatically and feeding it to final library.

---
 drivers/net/Makefile  |  3 +++
 lib/Makefile          |  3 +++
 mk/rte.sdkbuild.mk    |  2 +-
 mk/rte.sharelib.mk    |  3 +++
 scripts/merge_maps.sh | 29 +++++++++++++++++++++++++++++
 5 files changed, 39 insertions(+), 1 deletion(-)
 create mode 100755 scripts/merge_maps.sh
drivers/net/Makefile +3 -0
index cddcd57..d3c865b 100644
@@ -51,5 +51,8 @@ DIRS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += virtio
 DIRS-$(CONFIG_RTE_LIBRTE_VMXNET3_PMD) += vmxnet3
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_XENVIRT) += xenvirt
 
+ifeq ($(COMBINED_BUILD),1)
 include $(RTE_SDK)/mk/rte.sharelib.mk
+endif
+
 include $(RTE_SDK)/mk/rte.subdir.mk
lib/Makefile +3 -0
index ef172ea..d0f7fb8 100644
@@ -64,5 +64,8 @@ DIRS-$(CONFIG_RTE_LIBRTE_KNI) += librte_kni
 DIRS-$(CONFIG_RTE_LIBRTE_IVSHMEM) += librte_ivshmem
 endif
 
+ifeq ($(COMBINED_BUILD),1)
 include $(RTE_SDK)/mk/rte.sharelib.mk
+endif
+
 include $(RTE_SDK)/mk/rte.subdir.mk
mk/rte.sdkbuild.mk +1 -1
index 38ec7bd..d4e3abf 100644
@@ -94,7 +94,7 @@ $(ROOTDIRS-y):
 	@echo "== Build $@"
 	$(Q)$(MAKE) S=$@ -f $(RTE_SRCDIR)/$@/Makefile -C $(BUILDDIR)/$@ all
 	@if [ $@ = drivers -a $(CONFIG_RTE_BUILD_COMBINE_LIBS) = y ]; then \
-		$(MAKE) -f $(RTE_SDK)/lib/Makefile sharelib; \
+		COMBINED_BUILD=1 $(MAKE) -f $(RTE_SDK)/lib/Makefile sharelib; \
 	fi
 
 %_clean:
mk/rte.sharelib.mk +3 -0
index 7bb7219..76ead09 100644
@@ -40,6 +40,8 @@ LIB_ONE := lib$(RTE_LIBNAME).so
 else
 LIB_ONE := lib$(RTE_LIBNAME).a
 endif
+COMBINED_MAP=$(BUILDDIR)/lib/libdpdk.map
+CPU_LDFLAGS += --version-script=$(COMBINED_MAP)
 endif
 
 .PHONY:sharelib
@@ -79,6 +81,7 @@ ifeq ($(CONFIG_RTE_BUILD_COMBINE_LIBS),y)
 ifeq ($(CONFIG_RTE_BUILD_SHARED_LIB),y)
 $(LIB_ONE): FORCE
 	@[ -d $(dir $@) ] || mkdir -p $(dir $@)
+	@$(SRCDIR)/scripts/merge_maps.sh > $(COMBINED_MAP)
 	$(O_TO_S_DO)
 else
 $(LIB_ONE): FORCE
scripts/merge_maps.sh new file +29 -0
new file mode 100755
index 0000000..bc40dc8
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+FILES=$(find $RTE_SDK -name "*.map" | grep -v build)
+SYMBOLS=$(grep -h "{" $FILES | sort -u | sed 's/{//')
+
+first=0
+prev_sym="none"
+
+for s in $SYMBOLS; do
+	echo "$s {"
+	echo "    global:"
+	echo ""
+	for f in $FILES; do
+		sed -n "/$s {/,/}/p" $f | sed '/^$/d' | grep -v global | grep -v local | sed '1d' | sed '$d'
+	done | sort -u
+	echo ""
+	if [ $first -eq 0 ]; then
+		first=1;
+		echo "    local: *;";
+	fi
+	if [ "$prev_sym" == "none" ]; then
+		echo "};";
+		prev_sym=$s;
+	else
+		echo "} $prev_sym;";
+		prev_sym=$s;
+	fi
+	echo ""
+done
Signature · 1 line
2.5.0
#1 lore raw

Hi Ferruh,

Thanks for working on it.

2015-12-03 01:22, Ferruh Yigit:

Quoted 3 lines
drivers/net/Makefile +2 -0
+ifeq ($(COMBINED_BUILD),1)
 include $(RTE_SDK)/mk/rte.sharelib.mk
+endif

[...]

mk/rte.sdkbuild.mk $(ROOTDIRS-y): · line 97

Quoted 3 lines
mk/rte.sdkbuild.mk +1 -1
 	@if [ $@ = drivers -a $(CONFIG_RTE_BUILD_COMBINE_LIBS) = y ]; then \
-		$(MAKE) -f $(RTE_SDK)/lib/Makefile sharelib; \
+		COMBINED_BUILD=1 $(MAKE) -f $(RTE_SDK)/lib/Makefile sharelib; \

What is it fixing?
The badly named sharelib is for combined build only.

[...]

Quoted 1 line

+FILES=$(find $RTE_SDK -name "*.map" | grep -v build)

The build dir is not always "build/"

#2 lore raw
Quoted 9 lines · Thomas Monjalon

Hi Ferruh,

Thanks for working on it.

2015-12-03 01:22, Ferruh Yigit:

Quoted 3 lines
drivers/net/Makefile +2 -0
+ifeq ($(COMBINED_BUILD),1)
 include $(RTE_SDK)/mk/rte.sharelib.mk
+endif

[...]

Quoted 6 lines

mk/rte.sdkbuild.mk $(ROOTDIRS-y): · line 97

Quoted 3 lines
mk/rte.sdkbuild.mk +1 -1
 	@if [ $@ = drivers -a $(CONFIG_RTE_BUILD_COMBINE_LIBS) = y ]; then \
-		$(MAKE) -f $(RTE_SDK)/lib/Makefile sharelib; \
+		COMBINED_BUILD=1 $(MAKE) -f $(RTE_SDK)/lib/Makefile sharelib; \

What is it fixing?
The badly named sharelib is for combined build only.

lib/Makefile and drivers/net/Makefile includes sharelib.mk _always_, this flag is to include sharelib.mk only when we are compiling combined library.
Previously this inclusion was not problem because there was not common variable, now we start using common CPU_LDFLAGS variable and sharedlib.mk shouldn't included when not compiling for combined lib.

Quoted 6 lines

[...]

Quoted 1 line

+FILES=$(find $RTE_SDK -name "*.map" | grep -v build)

The build dir is not always "build/"

Thanks, I will fix this and send a new patch, I assume I can rely on "*_version.map" naming convention.

#3 lore raw

PATCH v3 1/1 mk: fix compile error and ABI versioning for combined shared library

Fixes following error (observed when versioning macros used):
LD libdpdk.so
/usr/bin/ld: /root/dpdk/build/lib/libdpdk.so: version node not found for symbol <function>@DPDK_x.y

Also resulting combined library contains symbol version information:

$ readelf -a build/lib/libdpdk.so | grep rte_eal_ | grep @ | head
   <...>    GLOBAL DEFAULT   12 rte_eal_alarm_set@@DPDK_2.0
   <...>    GLOBAL DEFAULT   12 rte_eal_pci_write_config@@DPDK_2.1
   <...>    GLOBAL DEFAULT   12 rte_eal_remote_launch@@DPDK_2.0
...

Versioning fixed by merging all version scripts into one automatically and feeding it to final library.

---
 drivers/net/Makefile  |  3 +++
 lib/Makefile          |  3 +++
 mk/rte.sdkbuild.mk    |  2 +-
 mk/rte.sharelib.mk    |  3 +++
 scripts/merge_maps.sh | 29 +++++++++++++++++++++++++++++
 5 files changed, 39 insertions(+), 1 deletion(-)
 create mode 100755 scripts/merge_maps.sh
drivers/net/Makefile +3 -0
index cddcd57..d3c865b 100644
@@ -51,5 +51,8 @@ DIRS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += virtio
 DIRS-$(CONFIG_RTE_LIBRTE_VMXNET3_PMD) += vmxnet3
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_XENVIRT) += xenvirt
 
+ifeq ($(COMBINED_BUILD),1)
 include $(RTE_SDK)/mk/rte.sharelib.mk
+endif
+
 include $(RTE_SDK)/mk/rte.subdir.mk
lib/Makefile +3 -0
index ef172ea..d0f7fb8 100644
@@ -64,5 +64,8 @@ DIRS-$(CONFIG_RTE_LIBRTE_KNI) += librte_kni
 DIRS-$(CONFIG_RTE_LIBRTE_IVSHMEM) += librte_ivshmem
 endif
 
+ifeq ($(COMBINED_BUILD),1)
 include $(RTE_SDK)/mk/rte.sharelib.mk
+endif
+
 include $(RTE_SDK)/mk/rte.subdir.mk
mk/rte.sdkbuild.mk +1 -1
index 38ec7bd..d4e3abf 100644
@@ -94,7 +94,7 @@ $(ROOTDIRS-y):
 	@echo "== Build $@"
 	$(Q)$(MAKE) S=$@ -f $(RTE_SRCDIR)/$@/Makefile -C $(BUILDDIR)/$@ all
 	@if [ $@ = drivers -a $(CONFIG_RTE_BUILD_COMBINE_LIBS) = y ]; then \
-		$(MAKE) -f $(RTE_SDK)/lib/Makefile sharelib; \
+		COMBINED_BUILD=1 $(MAKE) -f $(RTE_SDK)/lib/Makefile sharelib; \
 	fi
 
 %_clean:
mk/rte.sharelib.mk +3 -0
index 7bb7219..76ead09 100644
@@ -40,6 +40,8 @@ LIB_ONE := lib$(RTE_LIBNAME).so
 else
 LIB_ONE := lib$(RTE_LIBNAME).a
 endif
+COMBINED_MAP=$(BUILDDIR)/lib/libdpdk.map
+CPU_LDFLAGS += --version-script=$(COMBINED_MAP)
 endif
 
 .PHONY:sharelib
@@ -79,6 +81,7 @@ ifeq ($(CONFIG_RTE_BUILD_COMBINE_LIBS),y)
 ifeq ($(CONFIG_RTE_BUILD_SHARED_LIB),y)
 $(LIB_ONE): FORCE
 	@[ -d $(dir $@) ] || mkdir -p $(dir $@)
+	@$(SRCDIR)/scripts/merge_maps.sh > $(COMBINED_MAP)
 	$(O_TO_S_DO)
 else
 $(LIB_ONE): FORCE
scripts/merge_maps.sh new file +29 -0
new file mode 100755
index 0000000..4ace975
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+FILES=$(find $RTE_SDK -name "*_version.map")
+SYMBOLS=$(grep -h "{" $FILES | sort -u | sed 's/{//')
+
+first=0
+prev_sym="none"
+
+for s in $SYMBOLS; do
+	echo "$s {"
+	echo "    global:"
+	echo ""
+	for f in $FILES; do
+		sed -n "/$s {/,/}/p" $f | sed '/^$/d' | grep -v global | grep -v local | sed '1d' | sed '$d'
+	done | sort -u
+	echo ""
+	if [ $first -eq 0 ]; then
+		first=1;
+		echo "    local: *;";
+	fi
+	if [ "$prev_sym" == "none" ]; then
+		echo "};";
+		prev_sym=$s;
+	else
+		echo "} $prev_sym;";
+		prev_sym=$s;
+	fi
+	echo ""
+done
Signature · 1 line
2.5.0
#4 lore raw

2015-12-03 02:15, Ferruh Yigit:

drivers/net/Makefile DIRS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += virtio · line 56

Quoted 3 lines
drivers/net/Makefile +2 -0
+ifeq ($(COMBINED_BUILD),1)
 include $(RTE_SDK)/mk/rte.sharelib.mk
+endif

I still don't understand what was the issue with this include but it seems not related to versioning.
Please condider a separate patch with a detailed explanation of the bug.

[...]

Quoted 1 line

+FILES=$(find $RTE_SDK -name "*_version.map")

No, we can have several build directories in RTE_SDK.

#6 lore raw
In reply to Ferruh Yigit

Hi Ferruh,
some minor bash improvements that could be made in the next revision:

scripts/merge_maps.sh line 4

Quoted 10 lines · Ferruh Yigit
scripts/merge_maps.sh new file +4 -0
new file mode 100755
index 0000000..bc40dc8
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+FILES=$(find $RTE_SDK -name "*.map" | grep -v build)
+SYMBOLS=$(grep -h "{" $FILES | sort -u | sed 's/{//')

Guarding $RTE_SDK and $FILES with "" will help avoid some potential issues due to words splitting.

[...]

scripts/merge_maps.sh line 14

Quoted 1 line
scripts/merge_maps.sh new file +1 -0
+               sed -n "/$s {/,/}/p" $f | sed '/^$/d' | grep -v global | grep -v local | sed '1d' | sed '$d'

As above with $f

[...]

scripts/merge_maps.sh line 21

Quoted 1 line
scripts/merge_maps.sh new file +1 -0
+       if [ "$prev_sym" == "none" ]; then

Should be only one = as == is non standard and could fail in some environments.

Christian Ehrhardt
Software Engineer, Ubuntu Server
Canonical Ltd

#7 lore raw
Quoted 19 lines · Christian Ehrhardt

Hi Ferruh,
some minor bash improvements that could be made in the next revision:

scripts/merge_maps.sh line 4

Quoted 10 lines · Ferruh Yigit
scripts/merge_maps.sh new file +4 -0
new file mode 100755
index 0000000..bc40dc8
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+FILES=$(find $RTE_SDK -name "*.map" | grep -v build)
+SYMBOLS=$(grep -h "{" $FILES | sort -u | sed 's/{//')

Guarding $RTE_SDK and $FILES with "" will help avoid some potential issues due to words splitting.

[...]

Quoted 9 lines

scripts/merge_maps.sh line 14

Quoted 1 line
scripts/merge_maps.sh new file +1 -0
+               sed -n "/$s {/,/}/p" $f | sed '/^$/d' | grep -v global | grep -v local | sed '1d' | sed '$d'

As above with $f

[...]

scripts/merge_maps.sh line 21

Quoted 1 line
scripts/merge_maps.sh new file +1 -0
+       if [ "$prev_sym" == "none" ]; then

Should be only one = as == is non standard and could fail in some environments.

Thank you Christian, I will update accordingly.

Regards,
ferruh

#5 lore raw
In reply to Thomas Monjalon
Quoted 9 lines · Thomas Monjalon

2015-12-03 02:15, Ferruh Yigit:

drivers/net/Makefile DIRS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += virtio · line 56

Quoted 3 lines
drivers/net/Makefile +2 -0
+ifeq ($(COMBINED_BUILD),1)
 include $(RTE_SDK)/mk/rte.sharelib.mk
+endif

I still don't understand what was the issue with this include but it seems not related to versioning.
Please condider a separate patch with a detailed explanation of the bug.

Indeed this is related to the using versioning macros VERSION_SYMBOL, BIND_DEFAULT_SYMBOL But let me try to fix this in different way

Quoted 5 lines

[...]

Quoted 1 line

+FILES=$(find $RTE_SDK -name "*_version.map")

No, we can have several build directories in RTE_SDK.

"grep -v" was to remove build output .map files, not searching for _version.map, so it should be OK but let me narrow search path to lib and drivers folders to be safe

Thanks,
ferruh

#9 lore raw
In reply to Ferruh Yigit
Quoted 111 lines · Ferruh Yigit

Fixes following error (observed when versioning macros used):
LD libdpdk.so
/usr/bin/ld: /root/dpdk/build/lib/libdpdk.so: version node not found for symbol <function>@DPDK_x.y

Also resulting combined library contains symbol version information:

$ readelf -a build/lib/libdpdk.so | grep rte_eal_ | grep @ | head
    <...>    GLOBAL DEFAULT   12 rte_eal_alarm_set@@DPDK_2.0
    <...>    GLOBAL DEFAULT   12 rte_eal_pci_write_config@@DPDK_2.1
    <...>    GLOBAL DEFAULT   12 rte_eal_remote_launch@@DPDK_2.0
...

Versioning fixed by merging all version scripts into one automatically and feeding it to final library.

---
  drivers/net/Makefile  |  3 +++
  lib/Makefile          |  3 +++
  mk/rte.sdkbuild.mk    |  2 +-
  mk/rte.sharelib.mk    |  3 +++
  scripts/merge_maps.sh | 29 +++++++++++++++++++++++++++++
  5 files changed, 39 insertions(+), 1 deletion(-)

create mode 100755 scripts/merge_maps.sh

drivers/net/Makefile +3 -0
index cddcd57..d3c865b 100644
@@ -51,5 +51,8 @@ DIRS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += virtio
  DIRS-$(CONFIG_RTE_LIBRTE_VMXNET3_PMD) += vmxnet3
  DIRS-$(CONFIG_RTE_LIBRTE_PMD_XENVIRT) += xenvirt
 
+ifeq ($(COMBINED_BUILD),1)
  include $(RTE_SDK)/mk/rte.sharelib.mk
+endif
+
  include $(RTE_SDK)/mk/rte.subdir.mk
lib/Makefile +3 -0
index ef172ea..d0f7fb8 100644
@@ -64,5 +64,8 @@ DIRS-$(CONFIG_RTE_LIBRTE_KNI) += librte_kni
  DIRS-$(CONFIG_RTE_LIBRTE_IVSHMEM) += librte_ivshmem
  endif
 
+ifeq ($(COMBINED_BUILD),1)
  include $(RTE_SDK)/mk/rte.sharelib.mk
+endif
+
  include $(RTE_SDK)/mk/rte.subdir.mk
mk/rte.sdkbuild.mk +1 -1
index 38ec7bd..d4e3abf 100644
@@ -94,7 +94,7 @@ $(ROOTDIRS-y):
  	@echo "== Build $@"
  	$(Q)$(MAKE) S=$@ -f $(RTE_SRCDIR)/$@/Makefile -C $(BUILDDIR)/$@ all
  	@if [ $@ = drivers -a $(CONFIG_RTE_BUILD_COMBINE_LIBS) = y ]; then \
-		$(MAKE) -f $(RTE_SDK)/lib/Makefile sharelib; \
+		COMBINED_BUILD=1 $(MAKE) -f $(RTE_SDK)/lib/Makefile sharelib; \
  	fi
 
  %_clean:
mk/rte.sharelib.mk +3 -0
index 7bb7219..76ead09 100644
@@ -40,6 +40,8 @@ LIB_ONE := lib$(RTE_LIBNAME).so
  else
  LIB_ONE := lib$(RTE_LIBNAME).a
  endif
+COMBINED_MAP=$(BUILDDIR)/lib/libdpdk.map
+CPU_LDFLAGS += --version-script=$(COMBINED_MAP)
  endif
 
  .PHONY:sharelib
@@ -79,6 +81,7 @@ ifeq ($(CONFIG_RTE_BUILD_COMBINE_LIBS),y)
  ifeq ($(CONFIG_RTE_BUILD_SHARED_LIB),y)
  $(LIB_ONE): FORCE
  	@[ -d $(dir $@) ] || mkdir -p $(dir $@)
+	@$(SRCDIR)/scripts/merge_maps.sh > $(COMBINED_MAP)
  	$(O_TO_S_DO)
  else
  $(LIB_ONE): FORCE
scripts/merge_maps.sh new file +19 -0
new file mode 100755
index 0000000..bc40dc8
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+FILES=$(find $RTE_SDK -name "*.map" | grep -v build)
+SYMBOLS=$(grep -h "{" $FILES | sort -u | sed 's/{//')
+
+first=0
+prev_sym="none"
+
+for s in $SYMBOLS; do
+	echo "$s {"
+	echo "    global:"
+	echo ""
+	for f in $FILES; do
+		sed -n "/$s {/,/}/p" $f | sed '/^$/d' | grep -v global | grep -v local | sed '1d' | sed '$d'
+	done | sort -u
+	echo ""
+	if [ $first -eq 0 ]; then
+		first=1;
+		echo "    local: *;";

scripts/merge_maps.sh line 29

Quoted 10 lines
scripts/merge_maps.sh new file +10 -0
+	fi
+	if [ "$prev_sym" == "none" ]; then
+		echo "};";
+		prev_sym=$s;
+	else
+		echo "} $prev_sym;";
+		prev_sym=$s;
+	fi
+	echo ""
+done

I'd still rather see the combined library replaced with a linker script, but as long as it is there then +1 for this: with symbol versioning in place, applications linked to it more likely refuse to start than randomly crash when ABI changes, internal symbols are hidden etc. And doesn't require manual updating of two maps since its all scripted.

- Panu -

#10 lore raw

PATCH v4 1/1 mk: fix compile error and ABI versioning for combined shared library

Fixes following error (observed when versioning macros used):
LD libdpdk.so
/usr/bin/ld: /root/dpdk/build/lib/libdpdk.so: version node not found for symbol <function>@DPDK_x.y

Also resulting combined library contains symbol version information:

$ readelf -a build/lib/libdpdk.so | grep rte_eal_ | grep @ | head
   <...>    GLOBAL DEFAULT   12 rte_eal_alarm_set@@DPDK_2.0
   <...>    GLOBAL DEFAULT   12 rte_eal_pci_write_config@@DPDK_2.1
   <...>    GLOBAL DEFAULT   12 rte_eal_remote_launch@@DPDK_2.0
...

Versioning fixed by merging all version scripts into one automatically and feeding it to final library.

---
 mk/rte.sharelib.mk    |  6 +++++-
 scripts/merge_maps.sh | 29 +++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+), 1 deletion(-)
 create mode 100755 scripts/merge_maps.sh
mk/rte.sharelib.mk +5 -1
index 7bb7219..6029b71 100644
@@ -40,6 +40,8 @@ LIB_ONE := lib$(RTE_LIBNAME).so
 else
 LIB_ONE := lib$(RTE_LIBNAME).a
 endif
+COMBINED_MAP=$(BUILDDIR)/lib/libdpdk.map
+COMBINED_LDFLAGS += --version-script=$(COMBINED_MAP)
 endif
 
 .PHONY:sharelib
@@ -51,9 +53,10 @@ ifeq ($(LINK_USING_CC),1)
 # Override the definition of LD here, since we're linking with CC
 LD := $(CC) $(CPU_CFLAGS)
 O_TO_S = $(LD) $(call linkerprefix,$(CPU_LDFLAGS)) \
+	 $(call linkerprefix,$(COMBINED_LDFLAGS)) \
 	-shared $(OBJS) -o $(RTE_OUTPUT)/lib/$(LIB_ONE)
 else
-O_TO_S = $(LD) $(CPU_LDFLAGS) \
+O_TO_S = $(LD) $(CPU_LDFLAGS) $(COMBINED_LDFLAGS) \
 	-shared $(OBJS) -o $(RTE_OUTPUT)/lib/$(LIB_ONE)
 endif
 
@@ -79,6 +82,7 @@ ifeq ($(CONFIG_RTE_BUILD_COMBINE_LIBS),y)
 ifeq ($(CONFIG_RTE_BUILD_SHARED_LIB),y)
 $(LIB_ONE): FORCE
 	@[ -d $(dir $@) ] || mkdir -p $(dir $@)
+	@$(SRCDIR)/scripts/merge_maps.sh > $(COMBINED_MAP)
 	$(O_TO_S_DO)
 else
 $(LIB_ONE): FORCE
scripts/merge_maps.sh new file +29 -0
new file mode 100755
index 0000000..edc88de
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+FILES=$(find "$RTE_SDK"/lib "$RTE_SDK"/drivers -name "*_version.map")
+SYMBOLS=$(grep -h "{" $FILES | sort -u | sed 's/{//')
+
+first=0
+prev_sym="none"
+
+for s in $SYMBOLS; do
+	echo "$s {"
+	echo "    global:"
+	echo ""
+	for f in $FILES; do
+		sed -n "/$s {/,/}/p" "$f" | sed '/^$/d' | grep -v global | grep -v local | sed -e '1d' -e '$d'
+	done | sort -u
+	echo ""
+	if [ $first -eq 0 ]; then
+		first=1;
+		echo "    local: *;";
+	fi
+	if [ "$prev_sym" = "none" ]; then
+		echo "};";
+		prev_sym=$s;
+	else
+		echo "} $prev_sym;";
+		prev_sym=$s;
+	fi
+	echo ""
+done
Signature · 1 line
2.5.0
#8 lore raw
In reply to Ferruh Yigit
Quoted 5 lines · Ferruh Yigit
Quoted 4 lines · Christian Ehrhardt

Hi Ferruh,
some minor bash improvements that could be made in the next revision:

On Thu, Dec 3, 2015 at 2:22 AM, Ferruh Yigit <[email protected]> wrote:

Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
scripts/merge_maps.sh new file +0 -0
new file mode 100755
index 0000000..bc40dc8
Quoted 8 lines

scripts/merge_maps.sh line 4

Quoted 5 lines
scripts/merge_maps.sh new file +4 -0
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+FILES=$(find $RTE_SDK -name "*.map" | grep -v build)
+SYMBOLS=$(grep -h "{" $FILES | sort -u | sed 's/{//')

Guarding $RTE_SDK and $FILES with "" will help avoid some potential issues due to words splitting.

I quoted them (not $FILES which grep requires multiple params), but that will not actually help with folder names contains spaces, for that case script is broken. I fixed script using IFS and a few tricks but made script unnecessarly complex, so I revert back and leaving as it is unless required explicitly. And I suspect if folder name has spaces this script won't be only thing broken.

Thanks,
ferruh

#11 lore raw
In reply to Ferruh Yigit

2015-12-03 13:51, Ferruh Yigit:

Quoted 12 lines

Fixes following error (observed when versioning macros used):
LD libdpdk.so
/usr/bin/ld: /root/dpdk/build/lib/libdpdk.so: version node not found for symbol <function>@DPDK_x.y

Also resulting combined library contains symbol version information:

$ readelf -a build/lib/libdpdk.so | grep rte_eal_ | grep @ | head
   <...>    GLOBAL DEFAULT   12 rte_eal_alarm_set@@DPDK_2.0
   <...>    GLOBAL DEFAULT   12 rte_eal_pci_write_config@@DPDK_2.1
   <...>    GLOBAL DEFAULT   12 rte_eal_remote_launch@@DPDK_2.0
...
Quoted 4 lines

Versioning fixed by merging all version scripts into one automatically and feeding it to final library.

Applied, thanks

Quoted 1 line

+SYMBOLS=$(grep -h "{" $FILES | sort -u | sed 's/{//')

I think SYMBOLS would be better named as VERSIONS.