Flutter Engine
 
Loading...
Searching...
No Matches
elf_loader.h
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef FLUTTER_TESTING_ELF_LOADER_H_
6#define FLUTTER_TESTING_ELF_LOADER_H_
7
8#include <memory>
9
11#include "flutter/fml/macros.h"
12#include "third_party/dart/runtime/bin/elf_loader.h"
13
14namespace flutter::testing {
15
16inline constexpr const char* kDefaultAOTAppELFFileName = "app_elf_snapshot.so";
17
18// This file name is what gen_snapshot defaults to. It is based off of the
19// name of the base file, with the `2` indicating that this split corresponds
20// to loading unit id of 2. The base module id is 1 and is omitted as it is not
21// considered a split. If dart changes the naming convention, this should be
22// changed to match, however, this is considered unlikely to happen.
23inline constexpr const char* kDefaultAOTAppELFSplitFileName =
24 "app_elf_snapshot.so-2.part.so";
25
27 void operator()(Dart_LoadedElf* elf) { ::Dart_UnloadELF(elf); }
28};
29
30using UniqueLoadedELF = std::unique_ptr<Dart_LoadedElf, LoadedELFDeleter>;
31
34 const uint8_t* vm_snapshot_data = nullptr;
35 const uint8_t* vm_snapshot_instrs = nullptr;
36 const uint8_t* vm_isolate_data = nullptr;
37 const uint8_t* vm_isolate_instrs = nullptr;
38};
39
40//------------------------------------------------------------------------------
41/// @brief Attempts to resolve AOT symbols from the portable ELF loader.
42/// This location is automatically resolved from the fixtures
43/// generator. This only returns valid symbols when the VM is
44/// configured for AOT.
45///
46/// @param[in] elf_filename The AOT ELF filename from the fixtures generator.
47///
48/// @return The loaded ELF symbols.
49///
51
52//------------------------------------------------------------------------------
53/// @brief Attempts to resolve split loading unit AOT symbols from the
54/// portable ELF loader. If the dart code does not make use of
55/// deferred libraries, then there will be no split .so to load.
56/// This only returns valid symbols when the VM is configured for
57/// AOT.
58///
59/// @param[in] elf_split_filename The split AOT ELF filename from the fixtures
60/// generator.
61///
62/// @return The loaded ELF symbols.
63///
65 std::string elf_split_filename);
66
67//------------------------------------------------------------------------------
68/// @brief Prepare the settings objects various AOT mappings resolvers with
69/// the symbols already loaded. This method does nothing in non-AOT
70/// runtime modes.
71///
72/// @warning The symbols must not be collected till all shell instantiations
73/// made using the settings object are collected.
74///
75/// @param[in/out] settings The settings whose AOT resolvers to populate.
76/// @param[in] symbols The symbols used to populate the settings object.
77///
78/// @return If the settings object was correctly updated.
79///
81 const ELFAOTSymbols& symbols);
82
83} // namespace flutter::testing
84
85#endif // FLUTTER_TESTING_ELF_LOADER_H_
ELFAOTSymbols LoadELFSymbolFromFixturesIfNeccessary(std::string elf_filename)
Attempts to resolve AOT symbols from the portable ELF loader. This location is automatically resolved...
Definition elf_loader.cc:16
bool PrepareSettingsForAOTWithSymbols(Settings &settings, const ELFAOTSymbols &symbols)
Prepare the settings objects various AOT mappings resolvers with the symbols already loaded....
ELFAOTSymbols LoadELFSplitSymbolFromFixturesIfNeccessary(std::string elf_split_filename)
Attempts to resolve split loading unit AOT symbols from the portable ELF loader. If the dart code doe...
Definition elf_loader.cc:65
constexpr const char * kDefaultAOTAppELFSplitFileName
Definition elf_loader.h:23
constexpr const char * kDefaultAOTAppELFFileName
Definition elf_loader.h:16
std::unique_ptr< Dart_LoadedElf, LoadedELFDeleter > UniqueLoadedELF
Definition elf_loader.h:30
const uint8_t * vm_snapshot_data
Definition elf_loader.h:34
const uint8_t * vm_snapshot_instrs
Definition elf_loader.h:35
const uint8_t * vm_isolate_instrs
Definition elf_loader.h:37
const uint8_t * vm_isolate_data
Definition elf_loader.h:36
void operator()(Dart_LoadedElf *elf)
Definition elf_loader.h:27