[Android] fix link when 2 modules have same symbols
Thomas Guillem
git at videolan.org
Thu Feb 19 18:16:17 CET 2015
vlc-ports/android | branch: master | Thomas Guillem <thomas at gllm.fr> | Thu Feb 19 17:42:04 2015 +0100| [7cf134e81795f5726128e180f1234281b2dcddca] | committer: Thomas Guillem
fix link when 2 modules have same symbols
Rename static modules symbols in order to have unique symbols.
Close #13966
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=7cf134e81795f5726128e180f1234281b2dcddca
---
.gitignore | 1 +
compile-libvlc.sh | 44 +++++++++++++++++++++++++++++++++++++-------
2 files changed, 38 insertions(+), 7 deletions(-)
diff --git a/.gitignore b/.gitignore
index 8f225f0..70d741a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,6 +3,7 @@
# Android .so
/android-libs/**/*.so
+.modules/
# tmp dir used by gdb.sh
.gdb
diff --git a/compile-libvlc.sh b/compile-libvlc.sh
index 8c31dd2..6c87ef3 100755
--- a/compile-libvlc.sh
+++ b/compile-libvlc.sh
@@ -537,6 +537,10 @@ cd $SRC_DIR
# libVLC modules #
##################
+REDIFINED_VLC_MODULES_DIR=$SRC_DIR/.modules/${VLC_BUILD_DIR}
+rm -rf ${REDIFINED_VLC_MODULES_DIR}
+mkdir -p ${REDIFINED_VLC_MODULES_DIR}
+
echo "Generating static module list"
blacklist_regexp=
for i in ${VLC_MODULE_BLACKLIST}
@@ -548,24 +552,50 @@ do
blacklist_regexp="${blacklist_regexp}|${i}"
fi
done
-VLC_MODULES=`find vlc/$VLC_BUILD_DIR/modules -name 'lib*plugin.a' | grep -vE "lib(${blacklist_regexp})_plugin.a" | tr '\n' ' '`
+find_modules()
+{
+ echo "`find $1 -name 'lib*plugin.a' | grep -vE "lib(${blacklist_regexp})_plugin.a" | tr '\n' ' '`"
+}
+
+get_symbol()
+{
+ echo "$1" | grep vlc_entry_$2|cut -d" " -f 3
+}
+
+VLC_MODULES=$(find_modules vlc/$VLC_BUILD_DIR/modules)
DEFINITION="";
BUILTINS="const void *vlc_static_modules[] = {\n";
for file in $VLC_MODULES; do
- symbol=`"${CROSS_COMPILE}nm" -g $file | grep vlc_entry__|cut -d" " -f 3`
- DEFINITION=$DEFINITION"int $symbol (int (*)(void *, void *, int, ...), void *);\n"; \
- BUILTINS="$BUILTINS $symbol,\n"; \
-done; \
+ outfile=${REDIFINED_VLC_MODULES_DIR}/`basename $file`
+ name=`echo $file | sed 's/.*\.libs\/lib//' | sed 's/_plugin\.a//'`;
+ symbols=$("${CROSS_COMPILE}nm" -g $file)
+
+ # assure that all modules have differents entry symbols
+ entry=$(get_symbol "$symbols" _)
+ copyright=$(get_symbol "$symbols" copyright)
+ license=$(get_symbol "$symbols" license)
+ cat <<EOF > ${REDIFINED_VLC_MODULES_DIR}/syms
+$entry vlc_entry__$name
+$copyright vlc_entry_copyright__$name
+$license vlc_entry_license__$name
+EOF
+ ${CROSS_COMPILE}objcopy --redefine-syms ${REDIFINED_VLC_MODULES_DIR}/syms $file $outfile
+ checkfail "objcopy failed"
+
+ DEFINITION=$DEFINITION"int vlc_entry__$name (int (*)(void *, void *, int, ...), void *);\n";
+ BUILTINS="$BUILTINS vlc_entry__$name,\n";
+done;
BUILTINS="$BUILTINS NULL\n};\n"; \
-printf "/* Autogenerated from the list of modules */\n $DEFINITION\n $BUILTINS\n" > libvlc/jni/libvlcjni.h
+printf "/* Autogenerated from the list of modules */\n$DEFINITION\n$BUILTINS\n" > libvlc/jni/libvlcjni.h
+rm ${REDIFINED_VLC_MODULES_DIR}/syms
###############################
# NDK-Build for libvlcjni.so #
###############################
LIBVLC_LIBS="libvlcjni"
-VLC_MODULES=`echo $VLC_MODULES|sed "s|vlc/$VLC_BUILD_DIR|../vlc/$VLC_BUILD_DIR|g"`
+VLC_MODULES=$(find_modules ${REDIFINED_VLC_MODULES_DIR})
VLC_SRC_DIR="$SRC_DIR/vlc"
ANDROID_SYS_HEADERS="$SRC_DIR/android-headers"
VLC_CONTRIB="$VLC_SRC_DIR/contrib/$TARGET_TUPLE"
More information about the Android
mailing list