[PATCH] D51343: Fix RuntimeDyldCOFFX86_64 handling of image-relative relocations when there are not loaded sections

Andrew Scheidecker via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 9 12:21:43 PDT 2018


AndrewScheidecker updated this revision to Diff 164590.
AndrewScheidecker added a comment.

Added a comment


Repository:
  rL LLVM

https://reviews.llvm.org/D51343

Files:
  lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h


Index: lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h
===================================================================
--- lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h
+++ lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h
@@ -37,7 +37,13 @@
     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;
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51343.164590.patch
Type: text/x-patch
Size: 1007 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180909/8dd77c59/attachment.bin>


More information about the llvm-commits mailing list