diff options
| author | Brian Potchik <brian@vector35.com> | 2025-07-05 08:54:22 -0400 |
|---|---|---|
| committer | Brian Potchik <brian@vector35.com> | 2025-07-05 08:54:22 -0400 |
| commit | 4edbacc27800be28f890985898a29213da5a9135 (patch) | |
| tree | 75ecbeb620e084c7c1d7f5c5c2797eaae44374b0 /view/elf | |
| parent | b4d4a66337d4a8220f92710dc3c8895134c73cca (diff) | |
Fix ELF loader image base calculation to include memory-only PT_LOAD segments.
Diffstat (limited to 'view/elf')
| -rw-r--r-- | view/elf/elfview.cpp | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/view/elf/elfview.cpp b/view/elf/elfview.cpp index d7dc1203..536e016e 100644 --- a/view/elf/elfview.cpp +++ b/view/elf/elfview.cpp @@ -451,16 +451,15 @@ bool ElfView::Init() bool initialImageBaseSet = false; for (const auto& i : m_programHeaders) { - if ((i.type != ELF_PT_LOAD) || (!i.fileSize)) + // Skip segments that are not loadable or have no memory size + if ((i.type != ELF_PT_LOAD) || (i.memorySize == 0)) continue; - if (!initialImageBaseSet) + if (!initialImageBaseSet || (i.virtualAddress < initialImageBase)) { initialImageBase = i.virtualAddress; initialImageBaseSet = true; } - else if (i.virtualAddress < initialImageBase) - initialImageBase = i.virtualAddress; } SetOriginalImageBase(initialImageBase); |
