From c795ce7a67b8678635755070f171a3dab5f76b4c Mon Sep 17 00:00:00 2001 Message-Id: From: Kevin Kofler Date: Sat, 5 Oct 2013 00:22:51 +0200 Subject: [PATCH] Hide non-JNI symbols from native_ref-linux libs Add an ld version script to the GNU/Linux native_ref JNI libraries, hiding all the symbols except for the Java_* JNI symbols. This matches the other platforms, which only export explicitly exported symbols. GNU/Linux defaults to exporting all symbols. For C and C++ code, this can be overridden by compiling it with the -fvisibility=hidden flag, but gfortran does not support that flag, so it has to be done at link time through the --version-script linker flag. Without the symbol.map version script, all the symbols of the bundled reference BLAS, LAPACK and ARPACK (and also some internal functions of the JNI wrapper itself) were being exported, causing symbol conflicts. One example of such a symbol conflict is MATLAB: Loading JAVA code using netlib-java into MATLAB and using the native_ref implementation would crash MATLAB, due to symbol conflicts between MATLAB's versions of BLAS and LAPACK and the native_ref ones. (This was found during testing at the University of Vienna.) --- native_ref/xbuilds/linux-armhf/pom.xml | 1 + native_ref/xbuilds/linux-armhf/symbol.map | 1 + native_ref/xbuilds/linux-i686/pom.xml | 1 + native_ref/xbuilds/linux-i686/symbol.map | 1 + native_ref/xbuilds/linux-x86_64/pom.xml | 1 + native_ref/xbuilds/linux-x86_64/symbol.map | 1 + 6 files changed, 6 insertions(+) diff --git a/native_ref/xbuilds/linux-armhf/pom.xml b/native_ref/xbuilds/linux-armhf/pom.xml index 5ff05cc..d535a07 100644 --- a/native_ref/xbuilds/linux-armhf/pom.xml +++ b/native_ref/xbuilds/linux-armhf/pom.xml @@ -85,6 +85,7 @@ arm-rpi-linux-gnueabi-readelf -a target/netlib-native_ref-linux-armhf.so | grep --> -shared -lgfortran + -Wl,--version-script=symbol.map diff --git a/native_ref/xbuilds/linux-armhf/symbol.map b/native_ref/xbuilds/linux-armhf/symbol.map new file mode 100644 index 0000000..efba7df --- /dev/null +++ b/native_ref/xbuilds/linux-armhf/symbol.map @@ -0,0 +1 @@ +{ global: Java_*; local: *; }; diff --git a/native_ref/xbuilds/linux-i686/pom.xml b/native_ref/xbuilds/linux-i686/pom.xml index 61ac255..95462c7 100644 --- a/native_ref/xbuilds/linux-i686/pom.xml +++ b/native_ref/xbuilds/linux-i686/pom.xml @@ -80,6 +80,7 @@ -shared -lgfortran + -Wl,--version-script=symbol.map diff --git a/native_ref/xbuilds/linux-i686/symbol.map b/native_ref/xbuilds/linux-i686/symbol.map new file mode 100644 index 0000000..efba7df --- /dev/null +++ b/native_ref/xbuilds/linux-i686/symbol.map @@ -0,0 +1 @@ +{ global: Java_*; local: *; }; diff --git a/native_ref/xbuilds/linux-x86_64/pom.xml b/native_ref/xbuilds/linux-x86_64/pom.xml index 0bafb5f..edcbe06 100644 --- a/native_ref/xbuilds/linux-x86_64/pom.xml +++ b/native_ref/xbuilds/linux-x86_64/pom.xml @@ -67,6 +67,7 @@ -shared -lgfortran + -Wl,--version-script=symbol.map diff --git a/native_ref/xbuilds/linux-x86_64/symbol.map b/native_ref/xbuilds/linux-x86_64/symbol.map new file mode 100644 index 0000000..efba7df --- /dev/null +++ b/native_ref/xbuilds/linux-x86_64/symbol.map @@ -0,0 +1 @@ +{ global: Java_*; local: *; }; -- 1.8.1.4