Flutter Engine
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 
10 #include "flutter/common/settings.h"
11 #include "flutter/fml/macros.h"
12 #include "third_party/dart/runtime/bin/elf_loader.h"
13 
14 namespace flutter {
15 namespace testing {
16 
17 inline constexpr const char* kAOTAppELFFileName = "app_elf_snapshot.so";
18 
20  void operator()(Dart_LoadedElf* elf) { ::Dart_UnloadELF(elf); }
21 };
22 
23 using UniqueLoadedELF = std::unique_ptr<Dart_LoadedElf, LoadedELFDeleter>;
24 
25 struct ELFAOTSymbols {
27  const uint8_t* vm_snapshot_data = nullptr;
28  const uint8_t* vm_snapshot_instrs = nullptr;
29  const uint8_t* vm_isolate_data = nullptr;
30  const uint8_t* vm_isolate_instrs = nullptr;
31 };
32 
33 //------------------------------------------------------------------------------
34 /// @brief Attempts to resolve AOT symbols from the portable ELF loader.
35 /// This location is automatically resolved from the fixtures
36 /// generator. This only returns valid symbols when the VM is
37 /// configured for AOT.
38 ///
39 /// @return The loaded ELF symbols.
40 ///
42 
43 //------------------------------------------------------------------------------
44 /// @brief Prepare the settings objects various AOT mappings resolvers with
45 /// the symbols already loaded. This method does nothing in non-AOT
46 /// runtime modes.
47 ///
48 /// @warning The symbols must not be collected till all shell instantiations
49 /// made using the settings object are collected.
50 ///
51 /// @param[in/out] settings The settings whose AOT resolvers to populate.
52 /// @param[in] symbols The symbols used to populate the settings object.
53 ///
54 /// @return If the settings object was correctly updated.
55 ///
57  const ELFAOTSymbols& symbols);
58 
59 } // namespace testing
60 } // namespace flutter
61 
62 #endif // FLUTTER_TESTING_ELF_LOADER_H_
void operator()(Dart_LoadedElf *elf)
Definition: elf_loader.h:20
std::unique_ptr< Dart_LoadedElf, LoadedELFDeleter > UniqueLoadedELF
Definition: elf_loader.h:23
constexpr const char * kAOTAppELFFileName
Definition: elf_loader.h:17
ELFAOTSymbols LoadELFSymbolFromFixturesIfNeccessary()
Attempts to resolve AOT symbols from the portable ELF loader. This location is automatically resolved...
Definition: elf_loader.cc:15
bool PrepareSettingsForAOTWithSymbols(Settings &settings, const ELFAOTSymbols &symbols)
Prepare the settings objects various AOT mappings resolvers with the symbols already loaded...
Definition: elf_loader.cc:63