diff options
author | Sven Gothel <[email protected]> | 2013-06-16 19:16:31 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2013-06-16 19:16:31 +0200 |
commit | 5d211c6fa6a0452cc4569712e436184e34504a88 (patch) | |
tree | bdd90a5b7ccad4a3b62350c0b6699d3e0c66a92a /src/java/jogamp/common/os/BionicDynamicLinkerImpl.java | |
parent | d01cb422c4621fbc1b5ea2bcd7d19f3ff8602715 (diff) |
Fix DynamicLinker Impl: Add Bionic specialization using Bionic's non POSIX values; Using same pattern for Mac OS X.
Add Bionic specialization using Bionic's non POSIX values
- derive from UnixDynamicLinkerImpl
- specify own flag and mode values
- use UnixDynamicLinkerImpl native code
Using same pattern for Mac OS X
- derive from UnixDynamicLinkerImpl
- specify own flag and mode values
- use UnixDynamicLinkerImpl native code
- drop MacOSXDynamicLinkerImpl native code
Diffstat (limited to 'src/java/jogamp/common/os/BionicDynamicLinkerImpl.java')
-rw-r--r-- | src/java/jogamp/common/os/BionicDynamicLinkerImpl.java | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/java/jogamp/common/os/BionicDynamicLinkerImpl.java b/src/java/jogamp/common/os/BionicDynamicLinkerImpl.java new file mode 100644 index 0000000..3864ab2 --- /dev/null +++ b/src/java/jogamp/common/os/BionicDynamicLinkerImpl.java @@ -0,0 +1,54 @@ +package jogamp.common.os; + +import com.jogamp.common.util.SecurityUtil; + +/** + * Bionic specialization of {@link UnixDynamicLinkerImpl} + * utilizing Bionic's non POSIX flags and mode values. + * <p> + * Bionic is used on Android. + * </p> + */ +public class BionicDynamicLinkerImpl extends UnixDynamicLinkerImpl { + private static final long RTLD_DEFAULT = 0xffffffffL; + // static final long RTLD_NEXT = 0xfffffffeL; + + private static final int RTLD_LAZY = 0x00001; + // static final int RTLD_NOW = 0x00000; + private static final int RTLD_LOCAL = 0x00000; + private static final int RTLD_GLOBAL = 0x00002; + + // --- Begin CustomJavaCode .cfg declarations + public long openLibraryLocal(String pathname, boolean debug) throws SecurityException { + // Note we use RTLD_GLOBAL visibility to _NOT_ allow this functionality to + // be used to pre-resolve dependent libraries of JNI code without + // requiring that all references to symbols in those libraries be + // looked up dynamically via the ProcAddressTable mechanism; in + // other words, one can actually link against the library instead of + // having to dlsym all entry points. System.loadLibrary() uses + // RTLD_LOCAL visibility so can't be used for this purpose. + SecurityUtil.checkLinkPermission(pathname); + return dlopen(pathname, RTLD_LAZY | RTLD_LOCAL); + } + + public long openLibraryGlobal(String pathname, boolean debug) throws SecurityException { + // Note we use RTLD_GLOBAL visibility to allow this functionality to + // be used to pre-resolve dependent libraries of JNI code without + // requiring that all references to symbols in those libraries be + // looked up dynamically via the ProcAddressTable mechanism; in + // other words, one can actually link against the library instead of + // having to dlsym all entry points. System.loadLibrary() uses + // RTLD_LOCAL visibility so can't be used for this purpose. + SecurityUtil.checkLinkPermission(pathname); + return dlopen(pathname, RTLD_LAZY | RTLD_GLOBAL); + } + + public long lookupSymbolGlobal(String symbolName) { + final long addr = dlsym(RTLD_DEFAULT, symbolName); + if(DEBUG_LOOKUP) { + System.err.println("DynamicLinkerImpl.lookupSymbolGlobal("+symbolName+") -> 0x"+Long.toHexString(addr)); + } + return addr; + } + +} |