Exemplo n.º 1
0
  /**
   * Load a dynamic library
   *
   * @param libname the name of the library to load.
   * @return 0 on failure, 1 on success
   */
  public static synchronized int load(String libname) {
    VM_DynamicLibrary dl = dynamicLibraries.get(libname);
    if (dl != null) return 1; // success: already loaded

    if (VM_FileSystem.stat(libname, VM_FileSystem.STAT_EXISTS) == 1) {
      dynamicLibraries.put(libname, new VM_DynamicLibrary(libname));
      return 1;
    } else {
      return 0; // fail; file does not exist
    }
  }
Exemplo n.º 2
0
 /**
  * Resolve a symbol to an address in a currently loaded dynamic library.
  *
  * @return the address of the symbol of Address.zero() if it cannot be resolved
  */
 public static synchronized Address resolveSymbol(String symbol) {
   for (VM_DynamicLibrary lib : dynamicLibraries.values()) {
     Address symbolAddress = lib.getSymbol(symbol);
     if (!symbolAddress.isZero()) {
       return symbolAddress;
     }
   }
   return Address.zero();
 }