public final class DynamicLibrary extends Object
Modifier and Type | Field and Description |
---|---|
private static ImmutableEntryHashMapRVM<String,DynamicLibrary> |
dynamicLibraries
Currently loaded dynamic libraries.
|
private Address |
jniOnLoad
Address of JNI_OnLoad method
|
private Address |
jniOnUnload
Address of JNI_OnUnLoad
|
private Address |
libHandler
Value returned from dlopen
|
private String |
libName
The name of the library
|
Modifier | Constructor and Description |
---|---|
private |
DynamicLibrary(String libName,
Address libHandler)
Maintain a loaded library, call it's JNI_OnLoad function if present
|
Modifier and Type | Method and Description |
---|---|
static void |
boot()
Add symbol for the bootloader to find symbols within it.
|
private void |
callOnLoad()
Called after we've successfully loaded the shared library
|
private static void |
checkJNIVersion(int version)
Check JNI version is ≥ 1 and ≤ 1.4 and if not throw an
UnsatisfiedLinkError
|
void |
clean()
Tell the operating system to remove the dynamic library from the
system space.
|
private Address |
getJNI_OnLoad()
Get the unique JNI_OnLoad symbol associated with this library
|
private Address |
getJNI_OnUnload()
Get the unique JNI_OnUnload symbol associated with this library
|
String |
getLibName() |
Address |
getSymbol(String symbolName)
look up this dynamic library for a symbol
|
static int |
load(String libName)
Load a dynamic library
|
static Address |
resolveSymbol(String symbol)
Resolves a symbol to an address in a currently loaded dynamic library.
|
private static int |
runJNI_OnLoad(Address JNI_OnLoadAddress)
Method call to run the onload method.
|
String |
toString() |
void |
unload()
unload a dynamic library
|
private static final ImmutableEntryHashMapRVM<String,DynamicLibrary> dynamicLibraries
private final Address libHandler
private final Address jniOnUnload
private DynamicLibrary(String libName, Address libHandler)
libName
- library namelibHandler
- handle of loaded librarypublic static void boot()
private Address getJNI_OnLoad()
private Address getJNI_OnUnload()
private void callOnLoad()
private static int runJNI_OnLoad(Address JNI_OnLoadAddress)
JNI_OnLoadAddress
- address of JNI_OnLoad functionprivate static void checkJNIVersion(int version)
version
- to checkpublic String getLibName()
public Address getSymbol(String symbolName)
symbolName
- symbol nameAddress
of the symbol system handler
(or an address of a PowerPC Linkage triplet).
(-1: not found or couldn't be created)public void unload()
public void clean()
public static int load(String libName)
libName
- the name of the library to load.public static Address resolveSymbol(String symbol)
symbol
- the symbol to resolves