iree/hal/local/loaders/embedded_library_loader.c
// Resolves all of the imports declared by the executable using the given
// |import_provider|.
Resolves all of the imports declared by the executable using the given
|import_provider|.
Resolves all of the imports declared by the executable using the given |import_provider| .
static iree_status_t iree_hal_elf_executable_resolve_imports(
    iree_hal_elf_executable_t* executable,
    const iree_hal_executable_import_provider_t import_provider) {
  const iree_hal_executable_import_table_v0_t* import_table =
      &executable->library.v0->imports;
  if (!import_table->count) return iree_ok_status();
  IREE_TRACE_ZONE_BEGIN(z0);
  executable->base.import_thunk =
      (iree_hal_executable_import_thunk_v0_t)iree_elf_call_i_p;
  IREE_RETURN_AND_END_ZONE_IF_ERROR(
      z0, iree_allocator_malloc(
              executable->base.host_allocator,
              import_table->count * sizeof(*executable->base.imports),
              (void**)&executable->base.imports));
  for (uint32_t i = 0; i < import_table->count; ++i) {
    IREE_RETURN_AND_END_ZONE_IF_ERROR(
        z0,
        iree_hal_executable_import_provider_resolve(
            import_provider, iree_make_cstring_view(import_table->symbols[i]),
            (void**)&executable->base.imports[i]));
  }
  IREE_TRACE_ZONE_END(z0);
  return iree_ok_status();
}
static iree_status_t iree_hal_elf_executable_resolve_imports ( iree_hal_elf_executable_t * executable , const iree_hal_executable_import_provider_t import_provider ) { const iree_hal_executable_import_table_v0_t * import_table = & executable -> library . v0 -> imports ; if ( ! import_table -> count ) return iree_ok_status ( ) ; IREE_TRACE_ZONE_BEGIN ( z0 ) ; executable -> base . import_thunk = ( iree_hal_executable_import_thunk_v0_t ) iree_elf_call_i_p ; IREE_RETURN_AND_END_ZONE_IF_ERROR ( z0 , iree_allocator_malloc ( executable -> base . host_allocator , import_table -> count * sizeof ( * executable -> base . imports ) , ( void * * ) & executable -> base . imports ) ) ; for ( uint32_t i = 0 ; i < import_table -> count ; ++ i ) { IREE_RETURN_AND_END_ZONE_IF_ERROR ( z0 , iree_hal_executable_import_provider_resolve ( import_provider , iree_make_cstring_view ( import_table -> symbols [ i ] ) , ( void * * ) & executable -> base . imports [ i ] ) ) ; } IREE_TRACE_ZONE_END ( z0 ) ; return iree_ok_status ( ) ; }
Resolves all of the imports declared by the executable using the given
|import_provider|.
Resolves all of the imports declared by the executable using the given |import_provider| .
// All calls from the loaded ELF route through our thunk function so that we // can adapt to ABI differences. // Allocate storage for the imports. // Try to resolve each import. // NOTE: imports are sorted alphabetically and if we cared we could use this // information to more efficiently resolve the symbols from providers (O(n) // walk vs potential O(nlogn)/O(n^2)).