From f8ee0abca1fa6ed8eca530e4962df17ff384bc0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vivek=20Das=C2=A0Mohapatra?= <vivek@collabora.co.uk> Date: Wed, 24 May 2017 18:05:02 +0100 Subject: [PATCH] gen-stublib.sh: Include the major version of the proxied library When searching the ld cache, calling dlopen etc we cannot assume that there will be a libfoo.so linkk - or that it will point to the right major version of the library. Always search for an explcit libfoo.so.X target. Value of X is automatically parsed from the arguments to libtool. X defaults to 0. --- Makefile.am | 2 +- generate-stublib.sh | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 395544514..d8580b7b3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -73,7 +73,7 @@ include disabled.mk # explicitly depend on the generators and .excluded and .shared metafiles # depend on the .dlopen file IFF it exists shim/lib%.so.c: generate-stublib.sh print-libstubs capsule-shim.h shim/lib%.so.c.* - $(GENSTUB)$(top_srcdir)/$< $$(basename $@ .c) $@.excluded $@.shared $@ + $(GENSTUB)$(top_srcdir)/$< $$(basename $@ .c) $@.excluded $@.shared $@ "$(lib$(*)_la_LDFLAGS)"; debug: @echo srcs : $(shim_srcs) diff --git a/generate-stublib.sh b/generate-stublib.sh index 5d542138c..d0467fbe5 100755 --- a/generate-stublib.sh +++ b/generate-stublib.sh @@ -20,6 +20,18 @@ set -u set -e +major_version=0; + +parse_ldflags () +{ + while [ $# -ge 2 ] && [ "$1" != -version-number ]; do shift; done; + + if [ $# -ge 2 ] && [ "$1" = -version-number ] && [ -n "$2" ]; + then + major_version=${2%%:*}; + fi +} + declare -A NODE; top=$(dirname $0); top=${top:-.}; @@ -28,9 +40,16 @@ proxied_dso=$1; shift; proxy_excluded=$1; shift; proxy_extra=$1; shift; proxy_src=$1; shift; +ldflags=$1; shift; + +parse_ldflags $ldflags; + +proxied_dso=${proxied_dso%.so*}.so.${major_version}; + symbol_file=${proxy_src%.c}.symbols; map_file=${proxy_src%.c}.map; dlopen_file=${proxy_src}.dlopen; + echo -n > $symbol_file; echo -n > $map_file; -- GitLab