[PATCH] Hide non-JNI symbols from native_ref-linux libs #55
Comments
@kkofler thanks! I'll make sure this makes the 1.1 release. If you could send pull requests, instead of patches, in the future that would really help clean up my workflow. Github is great! |
@kkofler I can restrict the symbols on Linux and OS X, but if you ever want this for Windows too then you're going to have to create a I've uploaded the corrected binaries for all systems. Please try them and let me know if they work for you. I'm planning on making the 1.1 release this weekend. |
The symbols are already restricted there. (Just check your DLLs in any export viewer. Do not trust I also do not understand the changes you made to stripping. They may make sense on OS X (not sure), but on GNU/Linux, stripping is entirely unrelated to symbol exporting, it does not touch the dynamic symbol table (the table of exported symbols).You should just use |
PS: MinGW does provide a working tool to view the export table of a DLL (the equivalent of the dynamic symbol table of the GNU/Linux ELF format), it's called http://www.mirrorservice.org/sites/downloads.sourceforge.net/m/mi/mingw/MinGW/Extension/pexports/ Unfortunately, that tool is not part of the standard MinGW or cross-MinGW distributions. |
@kkofler if I do I'm running another compile with flags to remove unused code. I'll upload tonight. Re: Windows, see here http://sourceforge.net/p/mingw/bugs/1134/ specifically
so a |
I'm getting some assertion errors during the Raspberry Pi compile. I need to check that all the tests pass at the weekend before feeling comfortable enough to release this. |
We tried them at the university today (the snapshot that was current when you posted that comment), and we can confirm that they work fine. In particular, the native_ref .so no longer crashes MATLAB. (For what it's worth, the native_system library still triggers the same fatal symbol conflict, but we cannot fix that case in the same way, because the system BLAS/LAPACK libraries obviously have to export the symbols or they wouldn't work at all. It is really MATLAB's fault, I cannot think of any sane way to work around that right now. But at least native_ref works now.)
|
A .DEF file is required if you want anything other than the default behavior. But on Windows, exporting only the More precisely, MinGW (like Visual C++, whose behavior it emulates in this context) only exports functions marked as See:
So you can safely remove that TODO comment. Your code is already doing the right thing on Windows. |
well, I'm doing the symbol table lookup on windows just to be on the safe side. The native system libs you tried today weren't actually the new ones. I need to check the ARM bins before I can release: the dead code removal was causing assertion errors and I want to make sure the assertion errors were just overzealous warnings and not that my binaries are borked. |
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.)
I uploaded the patch exported from git to:
http://repo.calcforge.org/temp/0001-Hide-non-JNI-symbols-from-native_ref-linux-libs.patch
(because I cannot attach non-image files directly).
The text was updated successfully, but these errors were encountered: