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