9#include <fuchsia/io/cpp/fidl.h>
10#include <fuchsia/mem/cpp/fidl.h>
11#include <lib/fdio/directory.h>
12#include <lib/fdio/io.h>
13#include <lib/trace/event.h>
17#include <zircon/dlfcn.h>
18#include <zircon/status.h>
20#include "flutter/fml/logging.h"
21#include "third_party/dart/runtime/include/dart_api.h"
28static bool OpenVmo(fuchsia::mem::Buffer* resource_vmo,
30 const std::string&
path,
32 TRACE_DURATION(
"dart",
"LoadFromNamespace",
"path",
path);
34 if (namespc ==
nullptr) {
45 auto root_dir = fdio_ns_opendir(namespc);
63 const std::string&
path,
66 fuchsia::mem::Buffer resource_vmo;
67 return OpenVmo(&resource_vmo, namespc,
path, executable) &&
72 fuchsia::mem::Buffer resource_vmo,
75 if (resource_vmo.size == 0) {
79 uint32_t
flags = ZX_VM_PERM_READ;
81 flags |= ZX_VM_PERM_EXECUTE;
84 zx_status_t status = zx::vmar::root_self()->map(
flags, 0, resource_vmo.vmo, 0,
85 resource_vmo.size, &
addr);
86 if (status != ZX_OK) {
87 FML_LOG(
ERROR) <<
"Failed to map: " << zx_status_get_string(status);
97 if (address_ !=
nullptr) {
98 zx::vmar::root_self()->unmap(
reinterpret_cast<uintptr_t
>(address_), size_);
107 if (dirfd == AT_FDCWD) {
113 static_cast<uint32_t
>(fuchsia::io::OpenFlags::RIGHT_READABLE |
114 fuchsia::io::OpenFlags::RIGHT_EXECUTABLE),
120 static_cast<uint32_t
>(fuchsia::io::OpenFlags::RIGHT_READABLE |
121 fuchsia::io::OpenFlags::RIGHT_EXECUTABLE),
126 <<
"failed: " << zx_status_get_string(
result);
134 if (namespc ==
nullptr) {
137 root_dir = fdio_ns_opendir(namespc);
157 handle_ = Dart_LoadELF_Fd(fd, 0, &
error, &vm_data_, &vm_instrs_,
158 &isolate_data_, &isolate_instrs_);
159 if (handle_ ==
nullptr) {
static SkString resource(SkPDFResourceType type, int index)
bool Load(fdio_ns_t *namespc, const std::string &path)
static bool LoadFromNamespace(fdio_ns_t *namespc, const std::string &path, MappedResource &resource, bool executable=false)
static bool LoadFromVmo(const std::string &path, fuchsia::mem::Buffer resource_vmo, MappedResource &resource, bool executable=false)
FlutterSemanticsFlag flags
const uint8_t uint32_t uint32_t GError ** error
#define FML_LOG(severity)
#define FML_CHECK(condition)
bool VmoFromFilenameAt(int dirfd, const std::string &filename, bool executable, fuchsia::mem::Buffer *buffer)
static int OpenFdExec(const std::string &path, int dirfd)
bool VmoFromFilename(const std::string &filename, bool executable, fuchsia::mem::Buffer *buffer)
static bool OpenVmo(fuchsia::mem::Buffer *resource_vmo, fdio_ns_t *namespc, const std::string &path, bool executable)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
DART_EXPORT void Dart_UnloadELF(Dart_LoadedElf *loaded)