iree/hal/local/loaders/system_library_loader.c
static iree_status_t iree_hal_system_executable_load(
    iree_hal_system_executable_t* executable,
    iree_const_byte_span_t executable_data, iree_allocator_t host_allocator) {
  // Check to see if the library has a footer indicating embedded debug data.
  iree_const_byte_span_t library_data = iree_make_const_byte_span(NULL, 0);
  iree_const_byte_span_t debug_data = iree_make_const_byte_span(NULL, 0);
  const iree_hal_system_executable_footer_t* footer =
      iree_hal_system_executable_try_query_footer(executable_data);
  if (footer) {
    // Debug file present; split the data contents.
    iree_host_size_t data_length =
        executable_data.data_length - sizeof(*footer);
    if (footer->library_size > data_length ||
        footer->debug_offset + footer->debug_size > data_length) {
      return iree_make_status(
          IREE_STATUS_OUT_OF_RANGE,
          "system library footer references out of range bytes");
    }
    library_data =
        iree_make_const_byte_span(executable_data.data, footer->library_size);
    debug_data = iree_make_const_byte_span(
        executable_data.data + footer->debug_offset, footer->debug_size);
  } else {
    // Entire data contents are the library.
    library_data = executable_data;
  }

  IREE_RETURN_IF_ERROR(iree_dynamic_library_load_from_memory(
      iree_make_cstring_view("aot"), library_data,
      IREE_DYNAMIC_LIBRARY_FLAG_NONE, host_allocator, &executable->handle));

  if (debug_data.data_length > 0) {
    IREE_RETURN_IF_ERROR(iree_dynamic_library_attach_symbols_from_memory(
        executable->handle, debug_data));
  }

  return iree_ok_status();
}
// Loads the executable and optional debug database from the given
// |executable_data| in memory. The memory must remain live for the lifetime
// of the executable.
Loads the executable and optional debug database from the given
|executable_data| in memory. The memory must remain live for the lifetime
of the executable.
Loads the executable and optional debug database from the given |executable_data| in memory . The memory must remain live for the lifetime of the executable .
static iree_status_t iree_hal_system_executable_load(
    iree_hal_system_executable_t* executable,
    iree_const_byte_span_t executable_data, iree_allocator_t host_allocator) {
  iree_const_byte_span_t library_data = iree_make_const_byte_span(NULL, 0);
  iree_const_byte_span_t debug_data = iree_make_const_byte_span(NULL, 0);
  const iree_hal_system_executable_footer_t* footer =
      iree_hal_system_executable_try_query_footer(executable_data);
  if (footer) {
    iree_host_size_t data_length =
        executable_data.data_length - sizeof(*footer);
    if (footer->library_size > data_length ||
        footer->debug_offset + footer->debug_size > data_length) {
      return iree_make_status(
          IREE_STATUS_OUT_OF_RANGE,
          "system library footer references out of range bytes");
    }
    library_data =
        iree_make_const_byte_span(executable_data.data, footer->library_size);
    debug_data = iree_make_const_byte_span(
        executable_data.data + footer->debug_offset, footer->debug_size);
  } else {
    library_data = executable_data;
  }
  IREE_RETURN_IF_ERROR(iree_dynamic_library_load_from_memory(
      iree_make_cstring_view("aot"), library_data,
      IREE_DYNAMIC_LIBRARY_FLAG_NONE, host_allocator, &executable->handle));
  if (debug_data.data_length > 0) {
    IREE_RETURN_IF_ERROR(iree_dynamic_library_attach_symbols_from_memory(
        executable->handle, debug_data));
  }
  return iree_ok_status();
}
static iree_status_t iree_hal_system_executable_load ( iree_hal_system_executable_t * executable , iree_const_byte_span_t executable_data , iree_allocator_t host_allocator ) { iree_const_byte_span_t library_data = iree_make_const_byte_span ( NULL , 0 ) ; iree_const_byte_span_t debug_data = iree_make_const_byte_span ( NULL , 0 ) ; const iree_hal_system_executable_footer_t * footer = iree_hal_system_executable_try_query_footer ( executable_data ) ; if ( footer ) { iree_host_size_t data_length = executable_data . data_length - sizeof ( * footer ) ; if ( footer -> library_size > data_length || footer -> debug_offset + footer -> debug_size > data_length ) { return iree_make_status ( IREE_STATUS_OUT_OF_RANGE , " " ) ; } library_data = iree_make_const_byte_span ( executable_data . data , footer -> library_size ) ; debug_data = iree_make_const_byte_span ( executable_data . data + footer -> debug_offset , footer -> debug_size ) ; } else { library_data = executable_data ; } IREE_RETURN_IF_ERROR ( iree_dynamic_library_load_from_memory ( iree_make_cstring_view ( " " ) , library_data , IREE_DYNAMIC_LIBRARY_FLAG_NONE , host_allocator , & executable -> handle ) ) ; if ( debug_data . data_length > 0 ) { IREE_RETURN_IF_ERROR ( iree_dynamic_library_attach_symbols_from_memory ( executable -> handle , debug_data ) ) ; } return iree_ok_status ( ) ; }
Loads the executable and optional debug database from the given
|executable_data| in memory.
Loads the executable and optional debug database from the given |executable_data| in memory .
// Check to see if the library has a footer indicating embedded debug data. // Debug file present; split the data contents. // Entire data contents are the library.