upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/src/pe_loader.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/src/pe_loader.cpp')
-rw-r--r--runtime/src/pe_loader.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/runtime/src/pe_loader.cpp b/runtime/src/pe_loader.cpp
index caf5f0ad5..a0198c033 100644
--- a/runtime/src/pe_loader.cpp
+++ b/runtime/src/pe_loader.cpp
@@ -67,14 +67,16 @@ Module& Loader::load(const std::filesystem::path& image) {
67 std::string key = lower(image.filename().string()); 67 std::string key = lower(image.filename().string());
68 if (auto it = by_name_.find(key); it != by_name_.end()) return *it->second; 68 if (auto it = by_name_.find(key); it != by_name_.end()) return *it->second;
69 Module& m = map_image(image); 69 Module& m = map_image(image);
70 bind_imports(m); 70 bind_imports(m); // loads every bundled module m imports first, so they land in init_order_ before m
71 protect_sections(m); 71 protect_sections(m);
72 init_order_.push_back(&m);
72 return m; 73 return m;
73} 74}
74 75
75void Loader::initialise() { 76void Loader::initialise() {
76 // order_ is dependency order: a module is pushed after the modules it imports. 77 // Not order_: map_image pushes a module there before bind_imports maps its dependencies, so order_ lists an
77 for (auto* m : order_) initialise(*m); 78 // importer ahead of the DLLs it imports. init_order_ is filled once a module's imports are all loaded.
79 for (auto* m : init_order_) initialise(*m);
78} 80}
79 81
80void Loader::initialise(Module& m) { 82void Loader::initialise(Module& m) {