upleb.uk

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

summaryrefslogtreecommitdiff
path: root/runtime/test/loader_test.cpp
diff options
context:
space:
mode:
authorItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com>2026-11-22 13:17:26 -0500
committerItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com>2026-11-22 13:17:26 -0500
commit89d191af095053ce7f0df639aa4c70021df91039 (patch)
tree12df01bf9520bb314b36bf4ac0c2b72e7475c200 /runtime/test/loader_test.cpp
parentf8175dc5014379966530e3169440ec1508bc4787 (diff)
parent585143544e76954905535335ab98e7ab2ea7c23c (diff)
Merge pull request #2734 from admin
Diffstat (limited to 'runtime/test/loader_test.cpp')
-rw-r--r--runtime/test/loader_test.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/runtime/test/loader_test.cpp b/runtime/test/loader_test.cpp
index 3a4ced292..73bc49206 100644
--- a/runtime/test/loader_test.cpp
+++ b/runtime/test/loader_test.cpp
@@ -184,6 +184,28 @@ void expect_rejects(const char* what, const std::vector<uint8_t>& bytes) {
184 184
185void test_valid_image() { expect_loads("a valid image maps with its section intact", make_image()); } 185void test_valid_image() { expect_loads("a valid image maps with its section intact", make_image()); }
186 186
187void test_entry_bounds() {
188 for (bool is_dll : {false, true}) {
189 for (uint32_t entry : {0u, 0x1000u, 0x1FFFu, 0x2000u, 0x2001u}) {
190 auto img = make_image();
191 if (is_dll) nt_of(img)->FileHeader.Characteristics |= IMAGE_FILE_DLL;
192 nt_of(img)->OptionalHeader.AddressOfEntryPoint = entry;
193 const std::string what = std::string(is_dll ? "DLL" : "EXE") + " entry RVA " + std::to_string(entry);
194 if (entry < nt_of(img)->OptionalHeader.SizeOfImage) {
195 expect_loads(what.c_str(), img);
196 } else {
197 std::string error;
198 if (load(write_image(img), error) == 0)
199 failed(what.c_str(), "the image loaded");
200 else if (error.find("the entry point is outside the image") == std::string::npos)
201 failed(what.c_str(), "unexpected error: " + error);
202 else
203 pass(what.c_str());
204 }
205 }
206 }
207}
208
187void test_header_bounds() { 209void test_header_bounds() {
188 { 210 {
189 auto img = make_image(); 211 auto img = make_image();
@@ -1106,6 +1128,7 @@ int main() {
1106 return 1; 1128 return 1;
1107 } 1129 }
1108 test_valid_image(); 1130 test_valid_image();
1131 test_entry_bounds();
1109 test_header_bounds(); 1132 test_header_bounds();
1110 test_section_bounds(); 1133 test_section_bounds();
1111 test_truncation(); 1134 test_truncation();