diff options
author | Lang Hames <lhames@gmail.com> | 2018-10-23 01:36:33 +0000 |
---|---|---|
committer | Lang Hames <lhames@gmail.com> | 2018-10-23 01:36:33 +0000 |
commit | 776f1d50c8e56294274eaea90c51ca8d301e8e47 (patch) | |
tree | 6d6ff6244f1185c30748e5ead57db0fe40e7f677 /llvm/lib/ExecutionEngine/RuntimeDyld | |
parent | 3d16af69cfec6073c70d1e54d905b2fd155f25c7 (diff) | |
download | bcm5719-llvm-776f1d50c8e56294274eaea90c51ca8d301e8e47.tar.gz bcm5719-llvm-776f1d50c8e56294274eaea90c51ca8d301e8e47.zip |
[RuntimeDyld][COFF] Skip non-loaded sections when calculating ImageBase.
Non-loaded sections (whose unused load-address defaults to zero) should not
be taken into account when calculating ImageBase, or ImageBase will be
incorrectly set to 0.
Patch by Andrew Scheidecker. Thanks Andrew!
https://reviews.llvm.org/D51343
+ // The Sections list may contain sections that weren't loaded for
+ // whatever reason: they may be debug sections, and ProcessAllSections
+ // is false, or they may be sections that contain 0 bytes. If the
+ // section isn't loaded, the load address will be 0, and it should not
+ // be included in the ImageBase calculation.
llvm-svn: 344995
Diffstat (limited to 'llvm/lib/ExecutionEngine/RuntimeDyld')
-rw-r--r-- | llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h b/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h index 2d6e5c4aea6..39bdc4b6921 100644 --- a/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h +++ b/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h @@ -37,7 +37,13 @@ private: if (!ImageBase) { ImageBase = std::numeric_limits<uint64_t>::max(); for (const SectionEntry &Section : Sections) - ImageBase = std::min(ImageBase, Section.getLoadAddress()); + // The Sections list may contain sections that weren't loaded for + // whatever reason: they may be debug sections, and ProcessAllSections + // is false, or they may be sections that contain 0 bytes. If the + // section isn't loaded, the load address will be 0, and it should not + // be included in the ImageBase calculation. + if (Section.getLoadAddress() != 0) + ImageBase = std::min(ImageBase, Section.getLoadAddress()); } return ImageBase; } |